Do you know about closures? So something like: (defn foo [arg1 arg2] (fn [state] (do-something-with state arg1 arg2)))
- James On 25 November 2014 at 18:55, Isaac Karth <isaacka...@gmail.com> wrote: > I'm trying to build a string output system with functions that later have > a state passed to it, so that I can write something like (output "The > result of this example is: " (get :result)) and have it passed to a > parsing function that takes a state and calls the functions in the list, > something like (let [state] {:result "success"}](-> state (get > :result))). Basically, a delayed evaluation of the functions in the list > until they get the context later. > > I've gotten far enough that I can send an unevaluated list of > single-argument functions via(defmacro output [& data] `[~@data]) but > sending a function plus some arguments is trickier and I'm having trouble > working out the quoting and unquoting that needs to go on. > > Alternately, is there a better way to solve my original problem? > Basically, I want to have a concise and simple format to enter mostly text > with a few functions/variables and have it evaluated in a totally different > context later. Or maybe there's a parser or text processing library that > would handle this better? > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.