This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-24
Channels
- # admin-announcements (25)
- # beginners (132)
- # boot (89)
- # cider (26)
- # clara (12)
- # cljs-dev (10)
- # cljsrn (11)
- # clojure (151)
- # clojure-germany (8)
- # clojure-russia (1)
- # clojurescript (137)
- # cursive (33)
- # datavis (28)
- # datomic (3)
- # devcards (8)
- # hoplon (5)
- # immutant (11)
- # jobs (4)
- # ldnclj (58)
- # lein-figwheel (7)
- # off-topic (95)
- # om (114)
- # onyx (91)
- # parinfer (38)
- # portland-or (1)
- # re-frame (26)
- # reagent (1)
I see this error message : java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
I think the argument that you're passing to the anonymous function ( [f]
) is not a function but it's a number
so instead of invoking f
, you could rather use another function (operator function), to make this koan work
@roelof: think about what value ‘f’ will have
look up what alter takes as an argument
@roelof: you have given it a name locally in your fn
Try it
Remember the REPL is your friend.
I did understand a earlier one not right. I see that it have the same layout ( function arguments)
@roelof: not sure if you are doing this but I found it useful to have a repl open alongside Koans to allow me to experiment.
I also. I use Lighttable so I can evulate things quick. But sometimes I loose track and then the repl cannot help me
Anyone who can help me with this one : https://www.refheap.com/112021
I don’t know. I don’t use Lighttable. But considering that it was one of the first text editors to target Clojure, I would assume there is a plugin available somewhere.
stupid parentheses : now I have this problem: https://www.refheap.com/112023
I personally have never had the need to write a macro, so my macros fu is pretty terrible
but like in general, X cannot be cast to clojure.lang.IFn
means X
is the first thing in a list
I see now this : https://www.refheap.com/112024 so another error message
yeah, this time it might be your logic, I’m not so sure why you are applying r-infix to others
twice
hmmm, I did use instarepl of Light table and the problem is really which variable does have the value of the last part
The idea I have is to use map to iterate through the sequence and conj to a result vector only when % not= last result
But I can’t even get the function to return the vector without any when statement in the func
Running (mydedupe [1 1 2 3 3 2 2 3]) returns an empty vector, when I expect it should return the same vector.
result is an empty vector
And also what you are returning
Right, but your code is:
(let [result []]
(do something with no side effects)
result)
You may want to look into into
, if I'm reading what you're trying to do correctly
So what am I not understanding? Can I declare a local variable with let, modify it, and return the result?
You cannot do that - collections are immutable
(conj a-list "b")
returns a new list
a-list
is still whatever it was before the function
Well, map takes a function and runs it against the the collection
So while this doesn't really do what you want,
(defn mydedupe [s] (map identity s))
would be an example of you returning the same listLet me ask a basic question. Is it a workable strategy in Clojure to set up a result variable in a function and then build up a result using a loop or recur construct (such as map) and some logic? I was trying to use a let in the above code block, but since they are immutable, that won’t work.