Thanks! That fix also allowed me to get (_ . __) to work for [] as well which was giving the same error. Now, time to play around with multivar anonymous functions.\
Edit: Well never mind then, that change doesn't work in brackets.scm either so back to just playing with the macro.
What about having [...] expand to (fn (_ . __) ...) so that it would still keep its simplicity and be identical when only passing one argument, but when adding multiple arguments you can access them through __.
Both nil and (len str) work. I see both sides of the argument as counting from -1 eliminates the 0 corner case.
I like indices that are intuitive with literal numbers. Counting from 0 at one end and from 1 at the other is jarring. When -1 points to the end of string rather than before the last char (cut str 0 (- (len str))) returns the first char instead of the empty string.
With -1 -> before last char:
(def chop ((o str "abcdef"))
(pr "Chop how many chars off the end of \"" str "\"? ")
(= n (coerce (cut (readline) 1) 'int)) ; bug in readline prepends #\newline
(prn "Chopped: \"" (if (is n 0) str (cut str 0 (- n))) "\"")) ; handle corner case
With -1 -> end of string:
(def chop ((o str "abcdef"))
(pr "Chop how many chars off the end of \"" str "\"? ")
(= n (coerce (cut (readline) 1) 'int)) ; bug in readline prepends #\newline
(prn "Chopped: \"" (cut str 0 (- -1 n)) "\"")) ; no corner case, but there's this -1 there
I probably made a stronger argument for -1 pointing to the end of string as it leads to shorter code.
After thinking about it for a while this seems like the best approach. I really liked the suggestion to use '*' for the list but '__' seems the most natural after that.
I love python's 2 window environment but the functionality I'd like even more (and please point me to it if it already exists) would be the ability to dump the current REPL log to a file so that I could tinker completely in the REPL without constantly having to copy/paste to/from another file.