<laertus>is there an r5rs equivalent of "format" (ie. a function that does string interpolation) ? <laertus>or.. how does one do string interpolation in guile? <leoprikler>laertus: you mean stuff like "Hello, {world}\n", where {world} takes a value, e.g. Earth? <leoprikler>there also is SRFI-48, but since guile has its own format, I guess you won't find that here <leoprikler>if you already have string-typed variables, you can also use string-append <laertus>but it's not really string interpolation per se <laertus>is there a list somewhere of all ice-9 modules and what they do? <leoprikler>Kawa seems to have SRFI-109, but that also has a lot of other baggage <dsmith>"Output the fragments to the current output port. <dsmith>The fragments are a list of strings, characters, numbers, thunks, #f, #t – and other fragments. The function traverses the tree depth-first, writes out strings and characters, executes thunks, and ignores #f and '()." <dsmith>That's kind of schemey interpolation <dsmith>laertus: Pass it lists and strings and thunks and stuff. Never used it but seems useful. <dsmith>laertus: Also format in (ice-9 format) Pretty much the same as Common Lisp format. (it's like printf) <laertus>time to convert all my program's output to roman numerals... <laertus>thanks, but i think ice-9 format looks like more what i had in mind <dsmith>Ya. It's for when you want to control spaceing, number of decimals, leading +, etc. <laertus>i've been testing out using guile from gnu make... <laertus>and when i do $(guile (load "foo.scm")) it works, but make spits out annoying messages about compilation <laertus>like: "note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 or pass the --no-auto-compile argument to disable." <laertus>well, i guess i can try "GUILE_AUTO_COMPILE=0 make" <laertus>but say i do want to have guile do the compile, but just not tell me about it, in this particular case? <laertus>anyway, "GUILE_AUTO_COMPILE=0 make" doesn't seem to work <laertus>even when i don't modify my "foo.scm" file, make keeps warning me "note: source file foo.scm newer than compiled foo.scm.go" <laertus>i must say that it's really nice to be able to use guile from make, though <laertus>i've been bashing my head against its obtuse and convoluted syntax all day <laertus>it'll be such a relief to use a sane language for a change <apteryx>hello! how can I round a decimal number to the first digit, e.g.: 1.3234343 -> 1.3 ? <apteryx>this seems to do it: (format #f "~,1f" 1.32) -> 1.3 <laertus>does guile have something like emacs' #' operator, which in emacs is used to prefix quoted functions, like #'foo ? <laertus>so how do you pass a function to map? <laertus>in that case, still, i'd expect it'd be useful to differentiate between any old variable and one which contains a function <leoprikler>you can check, whether something is a procedure using procedure? <leoprikler>but i'd advice against making that into a reader syntax like e.g. #p(fun) <laertus>i guess for me the use of something like #'foo would be more a visual hint for the human reading the source that the intent here is that this thing is a function <laertus>kind of like using $foo for variables <leoprikler>if that really is important to you, try (define (ensure-procedure x) (if (procedure? x) x (error ...))) <leoprikler>of course you can make up your own conventions for procedure and variable names within your library <leoprikler>but hungarian notation is typically not adored by many <laertus>i've personally found it useful to instantly see the intent of the programmer with sigils like #'foo, $foo, or @foo <leoprikler>what would you do e.g. if you found (($mapper) $proc $list)? <laertus>you could have "clean" looking code, with no indication of what type something is, but then it's more error-prone ***sneek_ is now known as sneek
***apteryx is now known as Guest68452
***apteryx_ is now known as apteryx
<dsmith>laertus: Guile/Scheme is a lisp-1, emacs lisp (and common lisp) is a lisp-2. one namespace or two namespaces. <dsmith>in a lisp-2, a binding has a variable slot and a function slot. You access them differently <dsmith>In a lisp-1, it's just a variable. <dsmith>In scheme you can do ((if flag + *) 3 4) is 7 or 12 depending on flag. <dsmith>laertus: Guile *does* have a #' but it's used in macros. <leoprikler>is there a way of programmatically setting the duplicate handlers of a module? <leoprikler>i know, that (define-module ...) has some syntax around that, but I need to get to the nitty gritty of how that's implemented, because I can't define-module in that place <laertus>why does (simple-format #f "~S/~S" "foo" "bar") eval to "\"foo\"/\"bar\"" and not to "foo/bar" ? <laertus>simpler test case: i expect (simple-format #f "~S" "foo") to "foo" but it instead evals to "\"foo\"" <laertus>ice-9 format behaves pretty much the same way <d4ryus>laertus: You are looking for ~a, which outputs its argument like display. ~S will output them like write, this is handy if you want to read them back. Also note that ~a will prevent you from distinguishing symbols from strings. <laertus>because of this, it doesn't seem like either can be used for string interpolation like i wanted <d4ryus>e.g. (format #f "symbol: ~a string: ~a" 'test "test") => "symbol: test string: test" while ~S would return "symbol: test string: \"test\"". <laertus>another question: does guile have something like flatten? <str1ngs>leoprikler: (default-duplicate-binding-handler '(merge-generics replace warn-override-core warn last)) assuming you are using this in a none module? also you may not need merge-generics if you do not use goops <leoprikler>there are some flatten procedures (e.g. context-flatten from (ice-9 peg)) but afaik no "flatten" <laertus>what about some way to append one list on to the end of another? <leoprikler>str1ngs: I prefer the direct setter, but I just typo'd myself <str1ngs>leoprikler: I think that should work too. <laertus>is there a way to join a list of strings in to one string delimited by a user-supplied delimiter? <laertus>does guile have something like system* but which returns the stdout of the process back to guile? <dsmith>laertus: ya. can't remember the name right now. is in the piping module <laertus>does guile have a function like "nth", which evals to a certain element of a list? <laertus>nevermind.. found it... (list-ref '(a b c d) 3) ***jonsger1 is now known as jonsger
***sneek_ is now known as sneek