This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-23
Channels
- # admin-announcements (38)
- # announcements (1)
- # aws (1)
- # beginners (195)
- # boot (1)
- # business (3)
- # cider (100)
- # cljsrn (37)
- # clojure (99)
- # clojure-russia (69)
- # clojure-switzerland (1)
- # clojurescript (120)
- # datavis (26)
- # datomic (23)
- # devcards (4)
- # editors (38)
- # hoplon (18)
- # ldnclj (27)
- # lein-figwheel (28)
- # off-topic (50)
- # om (329)
- # onyx (255)
- # portland-or (1)
- # re-frame (8)
- # reagent (18)
- # spacemacs (5)
- # testing (1)
If anyone is interested in working through the Clojure for the Brave and True exercises in a cloud IDE, I've created a setup for http://www.codenvy.com where you can do this. I've made a few videos to show how: Part 1: https://www.youtube.com/watch?v=avDgIn4c-oc Part 2: https://www.youtube.com/watch?v=iZBVt2l_vOs Part 3: https://www.youtube.com/watch?v=5V9S_P7qTGw
Is late here so I'm off but feel free to PM if you are interested, have feedback, etc.
Great work @swizzard of explaining!
Well done @roelof
A symbol is usually something that resolves to a reference to either a function or a data value.
i.e. it’s a ‘variable name'
So b
is a symbol - but you have to quote it to prevent evaluation hence 'b
.
@roelof: plus *, +, !, -, _, ', and ?
you can’t begin or end a symbol with :
. and / are reserved (for Java interop and namespace qualification respectively)
and \ is used to escape things like characters i.e. \c is the Character ‘c’ not the String “c"
there are some reserved words of course, like ‘true’ and ‘false’ etc.
See http://clojure.org for full details http://clojure.org/reader
somehow I have to put something into the _ part so the function gives false on a odd number ?
What's 'not' to regret about being told the answer before having spent some time 'nutting it out'?
I have problems to understand why you need to decrease a number to know if a number is even
oke, I will try to read up on recursion on clojure and hopefully I will have a "light bulb" moment
I think solving this is not really a very good demonstration of recursion. It feels more like the author being ‘clever’ to me
Not a good practical demonstration, yet still I feel it helped me into the recursive mindset (such that I can be aware)
thanks both. I will read up with recursion on clojure and will try to solve this then first on paper
@roelof: not sure if this will help but think about what result should be returned if you input 1, then work out how you could just get this to occur by adding something at the placeholder. Then think about what the stack of function calls would be for 2
oke,, as far as I know there are two ways of reversing true and false. That are not and complement
half true… not reverses the boolean, while complement gives you another function of which the evaluation will give you the opposite
@roelof: now think about why - see my hint about the function call stack.
just stopping by 😉
but the guys have it all covered
just don’t let him be sloppy 😉 😈
but the guys are doing an awesome job here!!
No one is just giving you an answer, they’re asking great questions and make you think. It’s great to see
if I use complement, I still have to evalute this ? as not give me direct the reverse of true or false
try it out
BTW don’t try that with a -ve number!
meikemertsch: that is what I like about clojure and this channel. No answers , just explanations
@roelof: the Repl is your friend! 😄
negative number
Right
as you are decrementing
so you never reach the base condition (=n 0)
That one is a little bit like the ‘there is no spoon’ moment in The Matrix!
@meikemertsch: I hope you still are my "teacher"
The koans are the teacher, and the original Buddhist ones are to achieve the goal of life which is non attachment. Which is of course much harder than learning Clojure.
@roelof. Sure, but the cool thing is you don’t have to stick only to me you can tap into more than only one teacher
This is not a marriage 😂
roelof you have so many teachers. But I claim to be the original one who recommended doing koans to you!
Dropping out now again… see you later.. Guys, you’re doing a fine job, keep on doing it. It’s awesome 👍:skin-tone-2:
why does this loop never ends : https://www.refheap.com/111993
@roelof: you have two recursins in your function: 1. the recur and 2 the call to factorial
@roelof: you mixed two possible implementations of factorial: recursive and a loop (with loop
recur
)
@skammer: last example of this page : http://conj.io/store/v1/org.clojure/clojure/1.7.0/clj/clojure.core/loop ??
@skadinyo: last example of this page : http://conj.io/store/v1/org.clojure/clojure/1.7.0/clj/clojure.core/loop
I usually goes to http://clojuredocs.org/clojure.core/loop
I have now this code : https://www.refheap.com/111995
Whoops the last example does not seem to work. You could use samflores way, or you could add `'` to + or *. So instead of `*`, you can use `*'`
@samflores: the N makes also a bigint of it
inside your loop iter
and acc
are bound to integers and factorials grow big very fast 😄
you can also use 1M
to create a BigDecimal, but it's not very useful for this particular case
I know. I tried a time ago something like this and it could calculate till 45 if I right
How can I take care that in the named part there is no , between the named parts section
I have now this ; "You can regain the full argument if you like arguing" (= {:original-parts ["Stephen" "Hawking"] :named-parts {:first "Stephen" :last "Hawking"}} (let [[first-name last-name :as full-name] ["Stephen" "Hawking"]] {:orginal-parts [first-name last-name] :named-parts {:first first-name :last last-name}} )
Which gives : {:orginal-parts ["Stephen" "Hawking"], :named-parts {:first "Stephen", :last "Hawking"}}
can you paste code inside a snippet: For example:
new line then code then new line then
here the link to refheap : https://www.refheap.com/111996
that gives now : ` {:orginal-parts ["Stephen" "Hawking"], :named-parts {:first "Stephen", :last "Hawking"}}
instead of {:orginal-parts ["Stephen" "Hawking"], :named-parts {:first "Stephen" :last "Hawking"}}
are these good solutions : https://www.refheap.com/111997
thanks, I have the most doubt about the last one because there was only mention of test-adress
this one expects you destructure the two structures given ["Test" "Testerson"]
and test-address
let
is not the only place where you can use destructuring. the original koan is: (___ ["Test" "Testerson"] test-address)
. a good tip is to think what usually goes in the first element of a list 😉
(@roelof we were talking about this the other day—clojure makes a lot of assumptions about the first thing in a list)
I did solve that one this way : ((fn [[a b c]] (str "An Oxford comma list of " a ", " b ", and " c ".")) ["apples" "oranges" "pears"]))
that's what destructuring does: it breaks a compound data structure anywhere you would bind it to an Var (a function args vector or a let
bindings form)
oke, then I need two functions, One for the ["Test", "Testerson"] part and one for the adress part
no. you can destructure every argument of the function. you'll need a function that takes two arguments and destructure both
something like ((fn [ [a b] [{street-address :street-address, city :city, state :state} test-address]] printing part ["Test" "Testerson"] test-address))
@samflores: do I think now in the right direction
@samflores: can you help me one more time