Arc Forumnew | comments | leaders | submitlogin
2 points by conanite 6226 days ago | link | parent

Thanks. The behaviour of apply seems to be consistent with last-args-as-varargs.

  arc> (apply + "a" '("b" "c"))
  "abc"
I was originally thrown by a line in w/uniq in arc.arc -

  (apply + nil (map1 (fn (n) (list n '(uniq))) names))
This line is constructing an argument list for "with". It looks like the nil is necessary in case map1 returns an empty list, otherwise + would return 0, which is not a valid argument list.

(and thanks for the formatting tip)



1 point by absz 6225 days ago | link

The reason that w/uniq has the nil is so that + thinks it's adding lists, not numbers. Of course, pg could have just used join there, which would (a) eliminate the typing problem, and (b) in the nil case, produce (join), which is nil.

Also, if you want to reply directly to a person, click on the reply link below their post; it makes following the conversation a little bit smoother :)

-----