<tomoj> #(%1 %2) seems like it should have a name somehow
<amalloy> &(-> inc (.invoke 1))
<sexpbot> ⟹ 2
<amalloy> often almost as good as giving it a name
<tomoj> #(apply % %&) ?
<tomoj> does that do what I think it does
<amalloy> no
<amalloy> &(#(apply % %&) println 1)
<sexpbot> ⟹ 1 nil
<amalloy> oh. huh. maybe it does?
<amalloy> tomoj: i have a bad habit of asserting you are
wrong. i hope you don't mind
<tomoj> (apply #(apply % %&) f x y z) is (f x y z)
<tomoj> if people agree with me I see no real
need for them to say anything to me mostly
<amalloy> tomoj: sure. it's just that usually i'm *wrong* when i
tell you you're wrong :P
<tomoj> er
<tomoj> (f x y z) is (#(apply % %&) f x y z), right
<amalloy> tomoj: i assumed %& was "all the arguments", not "all
the args i haven't touched yet"
<amalloy> but apparently it's not
<amalloy> &'#(% %&)
<sexpbot> ⟹ (fn* (p1__17398#
rest__17399#))
<amalloy> &'#(%2 %&)
<sexpbot> ⟹ (fn*
(p2__17407# rest__17408#))
<tomoj> wacky
<amalloy> tomoj: how so?
<tomoj> the one disappears
<amalloy> well, naturally
<tomoj> that's interesting..
<amalloy> you're not
referring to it, and %& can't somehow include it
<tomoj> yeah
<clojurebot> excusez-moi
<tomoj> so is (#(apply % %&)
#(apply % %&) f x y z) also (f x y z)
<amalloy> *blink*
<tomoj> &(#(apply % %&) #(apply % %&)
#(apply % %&) #(apply % %&) + 1 2 3)
<sexpbot> ⟹ 6
<amalloy> i guess it must be
<tomoj> what is that strange thing
<amalloy> a delegator?
<tomoj> it's $
<amalloy> tomoj: i guess. but $ is only useful because of its
order of precedence
<amalloy> in a lisp it's not much good
<amalloy> i guess you can combine it with apply to get out
something useful
<tomoj> well, `($) ($) ($) ($) (+) 1 2` is 3
<amalloy> &(apply #(apply % %&) [+ 1 2)
<sexpbot> ⟹ 3 ; Adjusted to (apply (fn* (apply p1__17442# rest__17443#)) )
<tomoj> huh..
<tomoj> so.. (partial apply #(apply (resolve %) %&)) is almost like eval
<tomoj> but no macros, no special forms
ERC>
UPDATE: As amalloy later said, this doesn't resolve the other arguments, so it wouldn't work as an eval. Wow, is it close though :-p
No comments:
Post a Comment