There is no idiomatic way to do this in Clojure. If you explain the
problem (and not your proposed solution) we might be able to find a
nice and clean way of solving the problem.
Regards,
BG
--
Baishampayan Ghose
b.ghose at gmail.com
--
Name: OGINO Masanori (荻野 雅紀)
E-mail: masanor...@gmail.com
Hello,
I'm trying to pass a variable through a series of functions, which may
change the value of the variable. However, the next function in line
uses the original value, rather than the changed value. Here's a
pseudo-code of what I'm doing.
(defn process-1 [s]
; change value of s then return it
s)
(def s "something")
(do
(process-1 s) ; variable s is changed here
(process-2 s)) ; process-2 uses the original value of s, not the
return value from process-1
Thanks for the help.
Perhaps a sub-forum for beginners? Kind of embarrassing to ask here
questions that are so newbie-ish.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
> I'm trying to pass a variable through a series of functions, which may
> change the value of the variable. However, the next function in line
> uses the original value, rather than the changed value. Here's a
> pseudo-code of what I'm doing.
I think you should provide more context. Why, if that is the case at
all, do you want to pass an argument through functions that do not work
with it?
How many arguments does each fn in the line take (and what do they
evaluate to)?
Is it a fixed or a variable number of functions?
> Perhaps a sub-forum for beginners? Kind of embarrassing to ask here
> questions that are so newbie-ish.
Really no reason to feel embarrassed and I doubt the experts here would
like to monitor an additional space ...
--
Thorsten Wilms
thorwil's design for free software:
http://thorwil.wordpress.com/
> The determination of whether a called function will apply is left as a
> responsibility of the function itself, rather than the calling
> function. The motivation is that a function may be called from a
> number of places. Perhaps there's a better way?
The called function cannot decide to not be applied, but it may either
evaluate to its argument (assuming unary), or a value derived from that
argument.
I guess pattern matching would be nice here, but even without, you could
perhaps split the conditions from the actions. Is there any reason to
test additional rules after one matches, or would it be beneficial to
stop after a match? That would make it similar to URL routing like e.g.
Moustache does it.
From your description, it did sound like you want to call the 2nd
function with the original argument, not the result of the 1st function.
But how would you accumulate all the results, then?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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
(-> word fix-ou fix-ize)
(fix-ize (fix-ou word))
You can check it using clojure.walk/macroexpand-all.
user=> (macroexpand-all '(-> "labour" fix-ou fix-ize))
(fix-ize (fix-ou "labour"))
Indeed you can choose only one way, I suggest considering two ways.
Sometimes using -> is easy to read, and sometimes it is hard to do.
(Readability is the matter in this case, right?)
--
--