palingdrome problem (4 clojure)
Hello, I try to solve a problem for 4clojure where I have to make a palingdrome detector. So for trying I did this : (ns fourclojure.core (:gen-class)) (defn palingdrome [string] ( reverse string)) (apply str (palingdrome '( 1 2 3) )) '321' (apply str (palingdrome "Roelof" )) "foleoR" (defn palingdrome2 [string] ( reverse string)) (palingdrome2 '( 1 2 3) ) ( 3 2 1 ) (palingdrome2 "Roelof" ) (\f \o \l \e \o \R) So it works for a map or for a string. Is there a way I can make it work for both ? Roelof -- 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.
Re: palingdrome problem (4 clojure)
Thanks , that did the trick. Apperent; string/reverse works different from reverse One question : what does into do and does (empty x) means if x is empty or do you make a empty copy of x. Roelof Op woensdag 7 oktober 2015 20:07:00 UTC+2 schreef Moe Aboulkheir: > > Roelof, > > Something like this: > > (defn palindrome [x] > (if (string? x) > (clojure.string/reverse x) > (into (empty x) (reverse x > > Alternatively, you may want to consider explicitly using seq on your > inputs when you get them, and using that of the basis of comparison & input > to reverse. If you don't actually care about the concrete sequence type > (i.e. you only want sensible equality semantics after reversing something), > dropping it as soon as possible may be a better strategy. > > Take care, > Moe > > On Wed, Oct 7, 2015 at 6:51 PM, Roelof Wobben <wobben...@gmail.com > > wrote: > >> Hello, >> >> I try to solve a problem for 4clojure where I have to make a palingdrome >> detector. >> >> So for trying I did this : >> >> (ns fourclojure.core >> (:gen-class)) >> >> >> (defn palingdrome [string] >> ( reverse string)) >> >> (apply str (palingdrome '( 1 2 3) )) '321' >> (apply str (palingdrome "Roelof" )) "foleoR" >> >> (defn palingdrome2 [string] >> ( reverse string)) >> >> (palingdrome2 '( 1 2 3) ) ( 3 2 1 ) >> (palingdrome2 "Roelof" ) (\f \o \l \e \o \R) >> >> So it works for a map or for a string. >> >> Is there a way I can make it work for both ? >> >> Roelof >> >> >> >> -- >> 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 >> --- >> 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+u...@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.
Re: 4clojure count problem
Oke, then I hve to find out where to put the initial value. These two do not work : (reduce (fn [counter] (inc counter)) 0 [1,2,3]) (reduce (fn [counter] (inc counter) 0 ) [1,2,3]) Op zaterdag 3 oktober 2015 23:34:20 UTC+2 schreef Moe Aboulkheir: > > Roelof, > > Unless supplied with an initial value, reduce will use the first value > from the collection you supply - every sequence which doesn't start with > "1" will give you the wrong answer. > > Take care, > Moe > > On Sat, Oct 3, 2015 at 9:40 PM, Roelof Wobben <wobben...@gmail.com > > wrote: > >> Hello, >> >> I have to make a function which counts a collection without using count. >> >> So I came up with this : >> >> (fn [coll] (reduce (fn [counter _ ] (inc counter)) coll))) >> >> it works well with coll is [ 1 2 3] >> >> but it fails with "Hello World" >> >> How can I improve my code to work in both cases. >> >> Please , do not only give the answer but rather explain how I can make >> this work. >> So I learn a lot and not do only a copy/paste. >> >> Roelof >> >> -- >> 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 >> --- >> 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+u...@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.
Re: 4clojure count problem
Thanks, This solbved my problem. Roelof Op zondag 4 oktober 2015 11:51:49 UTC+2 schreef Moe Aboulkheir: > > Roelof, > > The function you're passing to reduce still wants to accept two > arguments. See the documentation: > https://clojuredocs.org/clojure.core/reduce > > Take care, > Moe > > On Sun, Oct 4, 2015 at 8:40 AM, Roelof Wobben <wobben...@gmail.com > > wrote: > >> Oke, then I hve to find out where to put the initial value. >> >> These two do not work : >> >> (reduce (fn [counter] (inc counter)) 0 [1,2,3]) >> (reduce (fn [counter] (inc counter) 0 ) [1,2,3]) >> >> Op zaterdag 3 oktober 2015 23:34:20 UTC+2 schreef Moe Aboulkheir: >>> >>> Roelof, >>> >>> Unless supplied with an initial value, reduce will use the first value >>> from the collection you supply - every sequence which doesn't start with >>> "1" will give you the wrong answer. >>> >>> Take care, >>> Moe >>> >>> On Sat, Oct 3, 2015 at 9:40 PM, Roelof Wobben <wobben...@gmail.com> >>> wrote: >>> >>>> Hello, >>>> >>>> I have to make a function which counts a collection without using count. >>>> >>>> So I came up with this : >>>> >>>> (fn [coll] (reduce (fn [counter _ ] (inc counter)) coll))) >>>> >>>> it works well with coll is [ 1 2 3] >>>> >>>> but it fails with "Hello World" >>>> >>>> How can I improve my code to work in both cases. >>>> >>>> Please , do not only give the answer but rather explain how I can make >>>> this work. >>>> So I learn a lot and not do only a copy/paste. >>>> >>>> Roelof >>>> >>>> -- >>>> 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 >>>> --- >>>> 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+u...@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 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 >> --- >> 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+u...@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.
4clojure count problem
Hello, I have to make a function which counts a collection without using count. So I came up with this : (fn [coll] (reduce (fn [counter _ ] (inc counter)) coll))) it works well with coll is [ 1 2 3] but it fails with "Hello World" How can I improve my code to work in both cases. Please , do not only give the answer but rather explain how I can make this work. So I learn a lot and not do only a copy/paste. Roelof -- 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.
Re: On Testing
Here a example where midje could provide more info. I have this function : (defn pr134 [element a-seq] (and (contains? a-seq element) (nil? element)) ) and I have this test-function : (ns exercises.core-test (:use midje.sweet) (:use [exercises.core])) (facts about `pr134` (fact it normally return true if the key exist and the value is nil (pr134 :a {:a nil :b 2}) = true (pr134 :b {:a nil :b 2}) = false )) Then I see this output : FAIL about `pr134` - it normally return true if the key exist and the value is nil at (core_test.clj:7) Expected: true Actual: false FAILURE: 1 check failed. (But 1 succeeded.) So I do not know if the first part contains? or the second one nil? is wrong. I know it mentioned before if you look at the way groovy does , you get more info like this made up example. (and (contains? a-seq element) (nil? element)) schould be true | | | true false | | | false true Roelof Op zondag 2 november 2014 03:04:38 UTC+1 schreef Devin Walters (devn): http://jakemccrary.com/blog/2014/06/22/comparing-clojure-testing-libraries-output/ has some good examples. I'm currently using humane-test-output. It's worked nicely for me. '(Devin Walters) On Nov 1, 2014, at 7:00 PM, Alex Miller al...@puredanger.com javascript: wrote: Additionally, I think it would be helpful to enumerate example (failing) tests and their output by current clojure.test. On Saturday, November 1, 2014 1:58:32 PM UTC-5, Alex Miller wrote: It would be great if someone could enumerate more explicitly what better test output means. What are the specific problems in the current test output reporting? Similar problem list for test runner might be useful. Discussion here is fine but ultimately needs to land on a design wiki page. I am happy to do what I can to move this through a process toward inclusion in a release. -- 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 javascript: 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 javascript: 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+u...@googlegroups.com javascript:. 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.
where do I think the wrong way
Hello, For a exercise I have to add something to the end of a existing map. So I thought this would work : (defn add-author [book new-author] (assoc book (conj :authors new-author))) and call the function with : (add-author little-schemer {:name Gerald J. Sussman}) then I see this error message : ClassCastException clojure.lang.Keyword cannot be cast to clojure.lang.IPersistentCollection clojure.core/conj (core.clj:83) Roelof -- 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.
Re: where do I think the wrong way
Thanks James, But how do I use assoc with it I tried this : (defn add-author [book new-author] (assoc book (conj (book :authors) new-author))) but then I see this message : ArityException Wrong number of args (2) passed to: core$assoc clojure.lang.AFn.throwArity (AFn.java:437) Roelof Op woensdag 29 oktober 2014 12:08:35 UTC+1 schreef James Reeves: On 29 October 2014 11:01, Roelof Wobben rwo...@hotmail.com javascript: wrote: For a exercise I have to add something to the end of a existing map. So I thought this would work : (defn add-author [book new-author] (assoc book (conj :authors new-author))) Take a look at that conj expression on its own: (conj :authors new-author) You're trying to conjoin new-author onto the keyword :authors, but keywords aren't collections. That's what the error means. It's saying that it expected a collection, but you've supplied a keyword instead. What you want is: (conj (get book :authors) new-author) Which can also be written: (conj (book :authors) new-author) (conj (:authors book) new-author) These two expressions are shortcuts for the above get function. They work because maps and keywords can act as functions. - James -- 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.
Re: where do I think the wrong way
Thanks all, It clear to me that I have to read the explanation or the right wiki page more carefully. I tried all of them and they all give the same answer : {:title zbook, :authors [{:name James} {:name Joe}]} Roelof Op woensdag 29 oktober 2014 13:34:32 UTC+1 schreef François Rey: (oops my earlier message isn't quite right, here's the correct one) You also need to clarify your intention: are you adding an author to a list of authors, or setting the single author? I suppose the first, but then you need to be clear on what the list of authors is. In idiomatic clojure you'll want it to be a vector of authors, so if an author is a map like {:name Gerald J. Sussman}, then :authors must be associated to a vector of maps. Also bear in mind that assoc is geared towards associative data structures such as maps, while conj is geared towards sequential data structures such as vectors. That being said, you can still use assoc on vectors (indices are the keys) and use conj on maps (with a vector in the form of [key value]), but that's polymorphism convenience, not idiomatic. In the end add to a new author, you need to do: (assoc book :authors (conj (get book :authors) new-author)) Which can also be made more idiomatic as already mentioned: (update-in book [:authors] assoc new-author) The twisted way of doing it would be: (conj book [:authors (conj (:authors book) new-author)]) Try this in a REPL: (def book {:title zbook :authors [{:name James}]}) (def new-author {:name Joe}) (assoc book :authors (conj (get book :authors) new-author)) (update-in book [:authors] conj new-author) (conj book [:authors (conj (:authors book) new-author)]) On 29/10/14 12:20, Roelof Wobben wrote: Thanks James, But how do I use assoc with it I tried this : (defn add-author [book new-author] (assoc book (conj (book :authors) new-author))) but then I see this message : ArityException Wrong number of args (2) passed to: core$assoc clojure.lang.AFn.throwArity (AFn.java:437) Roelof Op woensdag 29 oktober 2014 12:08:35 UTC+1 schreef James Reeves: On 29 October 2014 11:01, Roelof Wobben rwo...@hotmail.com wrote: For a exercise I have to add something to the end of a existing map. So I thought this would work : (defn add-author [book new-author] (assoc book (conj :authors new-author))) Take a look at that conj expression on its own: (conj :authors new-author) You're trying to conjoin new-author onto the keyword :authors, but keywords aren't collections. That's what the error means. It's saying that it expected a collection, but you've supplied a keyword instead. What you want is: (conj (get book :authors) new-author) Which can also be written: (conj (book :authors) new-author) (conj (:authors book) new-author) These two expressions are shortcuts for the above get function. They work because maps and keywords can act as functions. - James -- 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 javascript: 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 javascript: 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+u...@googlegroups.com javascript:. 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.
Re: testing platform , midje or specjl ?
Hello Colin, Do you know any good tutorials about learning clojure.test. ? Roelof Op dinsdag 28 oktober 2014 10:16:19 UTC+1 schreef Colin Yates: Hi Roelof, I have used midje for a few years now and it is excellent. It was the first one I picked up. However, I would recommend clojure.test *whilst learning* for a few reasons: - it is sufficient - it is opinionated and therefore keeps you on the straight and narrow - it is (probably) the best supported in terms of IDE support (emacs and CIDER for example) Midje is great, it really is. And although I haven't used any of the others (although I have looked at them and am very familiar with BDD) I am sure the same could be said of them. However, for me the question is one of focus and guidance. Part of midje's greatness is its flexibility. It supports top down, bottom up, makes mocking easy etc. None of which helps when the problem being solved is how do I do this *idiomatically*. clojure.test is much more opinionated, so if you are fighting the tool then that is a big flag that you might be doing something wrong right there. I picked up Midje for example and it allowed me to carry on writing OO code far longer than I should have. Had I used clojure.test then I wouldn't have had to fight some small incidental complexity battles (junit integration for example) and would have lost other battles I shouldn't have won (if you see what I mean). Ultimately, there are no wrong choices here - they are great. If it helps, I am starting a new project and starting off with clojure.test to see how far that gets me. This is more to do with grass is greener than anything else :). On Sunday, 26 October 2014 17:51:11 UTC, Roelof Wobben wrote: Hello, Im learning clojure as the beginnner. When im googeling for a testing platform there seems to be two major choices midje and specjl. Now I see that my learning course from github uses midje. Can I better learn midje and it this one still active maintained or can I better learn specjl. Roelof -- 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.
after updating clojure a repl error message
Hello, I updated my clojure from 1.5.1 to 1.6.0 and after I start lein repl I see this output : ERROR: Unhandled REPL handler exception processing message {:id cd35f8f4-8560-401e-8c70-466e00016c78, :op ack, :port 48024} java.net.SocketException: Socket closed at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:121) at java.net.SocketOutputStream.write(SocketOutputStream.java:159) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) at clojure.tools.nrepl.transport$bencode$fn__3186.invoke(transport.clj:103) at clojure.tools.nrepl.transport.FnTransport.send(transport.clj:28) at clojure.tools.nrepl.ack$handle_ack$fn__3312.invoke(ack.clj:42) at clojure.tools.nrepl.server$handle_STAR_.invoke(server.clj:18) at clojure.tools.nrepl.server$handle$fn__3634.invoke(server.clj:27) at clojure.core$binding_conveyor_fn$fn__4107.invoke(core.clj:1836) at clojure.lang.AFn.call(AFn.java:18) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) REPL-y 0.2.1 Clojure 1.6.0 Docs: (doc function-name-here)
Cannot understand why I get this output.
Hello, I have this facts. (def octavia {:name Octavia E. Butler :birth-year 1947 :death-year 2006}) (def wild-seed {:title Wild Seed, :authors [octavia]}) So I thought when I do this : (defn old-book-new-book [book] (get book :authors)) (old-book-new-book {:title Wild Seed, :authors [octavia]}) I see this output : [{:death-year 2006, :name Octavia E. Butler, :birth-year 1947}] where I expected it to be octavia or octavia E. Butler Can someone explain why I see the wrong output ? Roelof But I see this output : -- 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.
Re: Cannot understand why I get this output.
Op maandag 27 oktober 2014 16:07:15 UTC+1 schreef Gary Verhaegen: On Monday, 27 October 2014, Roelof Wobben rwo...@hotmail.com javascript: wrote: Now Im complete confused. I never succeed in reading the value of authors so I can do the set command. Roelof And now you're kind of confusing me. What makes you think you do not read the value of authors? What did you expect instead of what you got? I expected the outcome : *octavia* but I see the output : [{:death-year 2006, :name Octavia E. Butler, :birth-year 1947}] Roelof -- 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.
Re: Cannot understand why I get this output.
Op maandag 27 oktober 2014 16:37:49 UTC+1 schreef James Reeves: On 27 October 2014 13:45, Roelof Wobben rwo...@hotmail.com javascript: wrote: Hello, I have this facts. (def octavia {:name Octavia E. Butler :birth-year 1947 :death-year 2006}) So you've assigned the var octavia to the data structure: {:death-year 2006, :name Octavia E. Butler, :birth-year 1947} (def wild-seed {:title Wild Seed, :authors [octavia]}) Here you've assigned the var wild-seed to: {:title Wild Seed, :authors [octavia]} Which is the same as: {:title Wild Seed, :authors [{:death-year 2006, :name Octavia E. Butler, :birth-year 1947}]} So I thought when I do this : (defn old-book-new-book [book] (get book :authors)) (old-book-new-book {:title Wild Seed, :authors [octavia]}) Okay, so work through your code. You start with: (old-book-new-book {:title Wild Seed, :authors [octavia]}) Resolving this gets: (get {:title Wild Seed, :authors [octavia]} :authors) Resolving this gets: [octavia] Which resolves to: [{:death-year 2006, :name Octavia E. Butler, :birth-year 1947}] I'm not sure why you'd expect anything else. Did you not expect octavia to resolve? - James I think I do not fully understand how clojure works as a beginner. As far as I see it I have to find a way to stop with [octavia] so I can make a set of it. Roelof -- 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.
Re: Cannot understand why I get this output.
Thanks, I already understand what happens now. Im now trying to find a way to convert this :authors [octavia] to :authors #{octavia} Somehow I have to use set I think but I have to figure out how . Roelof Op maandag 27 oktober 2014 16:48:10 UTC+1 schreef Ashton Kemerling: I think you're confused on the terminal output. Try typing [octavia] in the repl, and compare the output you get to the above code. Clojure prints out the raw values of any computation, not variable names. On Mon, Oct 27, 2014 at 9:45 AM, Roelof Wobben rwo...@hotmail.com javascript: wrote: Op maandag 27 oktober 2014 16:37:49 UTC+1 schreef James Reeves: On 27 October 2014 13:45, Roelof Wobben rwo...@hotmail.com wrote: Hello, I have this facts. (def octavia {:name Octavia E. Butler :birth-year 1947 :death-year 2006}) So you've assigned the var octavia to the data structure: {:death-year 2006, :name Octavia E. Butler, :birth-year 1947} (def wild-seed {:title Wild Seed, :authors [octavia]}) Here you've assigned the var wild-seed to: {:title Wild Seed, :authors [octavia]} Which is the same as: {:title Wild Seed, :authors [{:death-year 2006, :name Octavia E. Butler, :birth-year 1947}]} So I thought when I do this : (defn old-book-new-book [book] (get book :authors)) (old-book-new-book {:title Wild Seed, :authors [octavia]}) Okay, so work through your code. You start with: (old-book-new-book {:title Wild Seed, :authors [octavia]}) Resolving this gets: (get {:title Wild Seed, :authors [octavia]} :authors) Resolving this gets: [octavia] Which resolves to: [{:death-year 2006, :name Octavia E. Butler, :birth-year 1947}] I'm not sure why you'd expect anything else. Did you not expect octavia to resolve? - James I think I do not fully understand how clojure works as a beginner. As far as I see it I have to find a way to stop with [octavia] so I can make a set of it. Roelof -- 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 javascript: 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 javascript: 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+u...@googlegroups.com javascript:. 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.
Re: Cannot understand why I get this output.
Thanks. I did a peek at the answer and it seems that this one do make it work. (defn old-book-new-book [book] (let [authors (get book :authors)] (assoc book :authors (set authors Roelof Edit 1 : I think I found it. The course is in 1.5.1 and im not trying it in 1.6.0 Op maandag 27 oktober 2014 16:55:32 UTC+1 schreef Gary Verhaegen: On Monday, 27 October 2014, Roelof Wobben rwob...@hotmail.com wrote: I expected the outcome : *octavia* but I see the output : [{:death-year 2006, :name Octavia E. Butler, :birth-year 1947}] Roelof I see. You will not get octavia as an outcome. The presentation in iloveponies seems to be slightly misleading. In the evaluation model for Clojure (and the vast majority of peogramming languages), arguments are evaluated first, and the language does not keep track of which expression produced a value. What is important to understand is that octavia has been resolved (repmaced by its associated value) even before the value is bound to wild-seed. If this is not clear for you, I'd say you've reached the limit of hands-on learning and it's time for some theory. You really need to understand the evaluation model before going further. A free resource I'd recommend for that is Aphyr's tutorial: http://aphyr.com/posts/301-clojure-from-the-ground-up-welcome If you have any money available, I would highly recommend Brian Marick's Functional Programming for the Object Oriented Programmer. If you have no experience with OOP, you will probably have trouble understanding the points of chapters 4 and on, but even then, I think the book is worth buying for the first three chapters, which have a great explanation of Clojure's evaluation model. -- 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.
Re: Cannot understand why I get this output.
Wierd, also on 1.5.1 I see the same output as 1.6.0. So there is a error in the page or the test are not checking it properly . Pity, this is a way I like to learn. Roelof Op maandag 27 oktober 2014 18:03:29 UTC+1 schreef Roelof Wobben: Thanks. I did a peek at the answer and it seems that this one do make it work. (defn old-book-new-book [book] (let [authors (get book :authors)] (assoc book :authors (set authors Roelof Edit 1 : I think I found it. The course is in 1.5.1 and im not trying it in 1.6.0 Op maandag 27 oktober 2014 16:55:32 UTC+1 schreef Gary Verhaegen: On Monday, 27 October 2014, Roelof Wobben rwob...@hotmail.com wrote: I expected the outcome : *octavia* but I see the output : [{:death-year 2006, :name Octavia E. Butler, :birth-year 1947}] Roelof I see. You will not get octavia as an outcome. The presentation in iloveponies seems to be slightly misleading. In the evaluation model for Clojure (and the vast majority of peogramming languages), arguments are evaluated first, and the language does not keep track of which expression produced a value. What is important to understand is that octavia has been resolved (repmaced by its associated value) even before the value is bound to wild-seed. If this is not clear for you, I'd say you've reached the limit of hands-on learning and it's time for some theory. You really need to understand the evaluation model before going further. A free resource I'd recommend for that is Aphyr's tutorial: http://aphyr.com/posts/301-clojure-from-the-ground-up-welcome If you have any money available, I would highly recommend Brian Marick's Functional Programming for the Object Oriented Programmer. If you have no experience with OOP, you will probably have trouble understanding the points of chapters 4 and on, but even then, I think the book is worth buying for the first three chapters, which have a great explanation of Clojure's evaluation model. -- 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.
Re: Cannot understand why I get this output.
of course I can. If I look at answers other people gives then this is the solution : (defn old-book-new-book [book] (assoc book :authors (set (book :authors))) ) and then according to the explanation I would see this output ; (old-book-new-book {:title Wild Seed, :authors [octavia]});= {:title Wild Seed, :authors #{octavia}} but on 1.6.0 and on 1.5.1 I see another output as discussed here. But it seems that midje has aprove this solution so or midje checks against another output And then the tekst on the tutorial is very wrong. Or midje checks and aproves the wrong answer ( the answer in the text) and aproves the wrong answer. Roelof On Monday, October 27, 2014 8:24:12 PM UTC+1, James Reeves wrote: On 27 October 2014 19:16, Roelof Wobben rwo...@hotmail.com javascript: wrote: Wierd, also on 1.5.1 I see the same output as 1.6.0. So there is a error in the page or the test are not checking it properly . Could you explain what you think is an error? Your messages are a little cryptic. - James -- 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.
Re: Cannot understand why I get this output.
nope, there is somewhere a error in the example. When I copie it as you made it then I see this error message : RuntimeException Unmatched delimiter: } clojure.lang.Util.runtimeException (Util.java:219) when I add a extra ) I see this message : RuntimeException Map literal must contain an even number of forms clojure.lang.Util.runtimeException (Util.java:219) Roelof Op maandag 27 oktober 2014 20:46:49 UTC+1 schreef James Reeves: On 27 October 2014 19:37, Roelof Wobben rwo...@hotmail.com javascript: wrote: of course I can. If I look at answers other people gives then this is the solution : (defn old-book-new-book [book] (assoc book :authors (set (book :authors))) ) and then according to the explanation I would see this output ; (old-book-new-book {:title Wild Seed, :authors [octavia]});= {:title Wild Seed, :authors #{octavia}} but on 1.6.0 and on 1.5.1 I see another output as discussed here. I don't think you're understanding that: {:title Wild Seed, :authors #{{:name Octavia E. Butler, :birth-year 1947, :death-year 2006}}} Evaluates to the same thing as: {:title Wild Seed, :authors #{octavia}} The difference is that in the first value, octavia has been replaced with its value. You can confirm the two data structures are the same by checking their equality: (= {:title Wild Seed, :authors #{{:name Octavia E. Butler, :birth-year 1947, :death-year 2006}} {:title Wild Seed, :authors #{octavia}}} This should return true. - James -- 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.
Re: Cannot understand why I get this output.
Np, So if I understand it right. I see the first one in repl. Because midje has #{octavia} and in another function is stated : (def octavia {:name Octavia E. Butler :birth-year 1947 :death-year 2006}) clojure makes from the first {octavia} the second {:name Octavia E. Butler :birth-year 1947 :death-year 2006}) so that is why there are both the same. Roelof Op maandag 27 oktober 2014 22:09:04 UTC+1 schreef James Reeves: Sorry, I misplaced a couple of brackets: (= {:title Wild Seed, :authors #{{:name Octavia E. Butler, :birth-year 1947, :death-year 2006}}} {:title Wild Seed, :authors #{octavia}}) That should work. - James On 27 October 2014 20:20, Roelof Wobben rwo...@hotmail.com javascript: wrote: nope, there is somewhere a error in the example. When I copie it as you made it then I see this error message : RuntimeException Unmatched delimiter: } clojure.lang.Util.runtimeException (Util.java:219) when I add a extra ) I see this message : RuntimeException Map literal must contain an even number of forms clojure.lang.Util.runtimeException (Util.java:219) Roelof Op maandag 27 oktober 2014 20:46:49 UTC+1 schreef James Reeves: On 27 October 2014 19:37, Roelof Wobben rwo...@hotmail.com wrote: of course I can. If I look at answers other people gives then this is the solution : (defn old-book-new-book [book] (assoc book :authors (set (book :authors))) ) and then according to the explanation I would see this output ; (old-book-new-book {:title Wild Seed, :authors [octavia]});= {:title Wild Seed, :authors #{octavia}} but on 1.6.0 and on 1.5.1 I see another output as discussed here. I don't think you're understanding that: {:title Wild Seed, :authors #{{:name Octavia E. Butler, :birth-year 1947, :death-year 2006}}} Evaluates to the same thing as: {:title Wild Seed, :authors #{octavia}} The difference is that in the first value, octavia has been replaced with its value. You can confirm the two data structures are the same by checking their equality: (= {:title Wild Seed, :authors #{{:name Octavia E. Butler, :birth-year 1947, :death-year 2006}} {:title Wild Seed, :authors #{octavia}}} This should return true. - James -- 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.
Re: Cannot understand why I get this output.
Thanks all persons for the help and patience with me. Roelof Op maandag 27 oktober 2014 22:23:50 UTC+1 schreef James Reeves: Right. It's similar to writing: (def x 5) (= #{x} #{5}) You'd expect that to be true, right? When Clojure comes across an unquoted symbol (like x or octavia), it tries to evaluate it, replacing it with the value it represents. In a similar way, unquoted lists (anything in parentheses) are also evaluated as functions, macros or special forms. So: (= #{x} #{5}) Becomes: (= #{5} #{5}) Becomes: true - James On 27 October 2014 21:16, Roelof Wobben rwo...@hotmail.com javascript: wrote: Np, So if I understand it right. I see the first one in repl. Because midje has #{octavia} and in another function is stated : (def octavia {:name Octavia E. Butler :birth-year 1947 :death-year 2006}) clojure makes from the first {octavia} the second {:name Octavia E. Butler :birth-year 1947 :death-year 2006}) so that is why there are both the same. Roelof Op maandag 27 oktober 2014 22:09:04 UTC+1 schreef James Reeves: Sorry, I misplaced a couple of brackets: (= {:title Wild Seed, :authors #{{:name Octavia E. Butler, :birth-year 1947, :death-year 2006}}} {:title Wild Seed, :authors #{octavia}}) That should work. - James On 27 October 2014 20:20, Roelof Wobben rwo...@hotmail.com wrote: nope, there is somewhere a error in the example. When I copie it as you made it then I see this error message : RuntimeException Unmatched delimiter: } clojure.lang. Util.runtimeException (Util.java:219) when I add a extra ) I see this message : RuntimeException Map literal must contain an even number of forms clojure.lang.Util.runtimeException (Util.java: 219) Roelof Op maandag 27 oktober 2014 20:46:49 UTC+1 schreef James Reeves: On 27 October 2014 19:37, Roelof Wobben rwo...@hotmail.com wrote: of course I can. If I look at answers other people gives then this is the solution : (defn old-book-new-book [book] (assoc book :authors (set (book :authors))) ) and then according to the explanation I would see this output ; (old-book-new-book {:title Wild Seed, :authors [octavia]});= {:title Wild Seed, :authors #{octavia}} but on 1.6.0 and on 1.5.1 I see another output as discussed here. I don't think you're understanding that: {:title Wild Seed, :authors #{{:name Octavia E. Butler, :birth-year 1947, :death-year 2006}}} Evaluates to the same thing as: {:title Wild Seed, :authors #{octavia}} The difference is that in the first value, octavia has been replaced with its value. You can confirm the two data structures are the same by checking their equality: (= {:title Wild Seed, :authors #{{:name Octavia E. Butler, :birth-year 1947, :death-year 2006}} {:title Wild Seed, :authors #{octavia}}} This should return true. - James -- 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.
testing platform , midje or specjl ?
Hello, Im learning clojure as the beginnner. When im googeling for a testing platform there seems to be two major choices midje and specjl. Now I see that my learning course from github uses midje. Can I better learn midje and it this one still active maintained or can I better learn specjl. Roelof -- 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.
map problem (Ilove ponies)
Hello, I have to use map and get a vector of all the second items in a list. I know I can use map to do things with all the items in a list. and with get I can get the second item (get collection 1) map uses this map what_has _to_be_done collection so I thougt this would work (map (get collection 1) collection) but then I see this error message : java.lang.IllegalArgumentException: Key must be integer where did my thinking get the wrong turn ? Roelof -- 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.
Re: map problem (Ilove ponies)
Op vrijdag 24 oktober 2014 14:09:13 UTC+2 schreef Laurens Van Houtven: Hi Roelof, On 24 Oct 2014, at 14:05, Roelof Wobben rwo...@hotmail.com javascript: wrote: I have to use map and get a vector of all the second items in a list. I know I can use map to do things with all the items in a list. and with get I can get the second item (get collection 1) Yes, depending on what the items in the list are. For vectors, for example, that will work. map uses this map what_has _to_be_done collection so I thougt this would work (map (get collection 1) collection) but then I see this error message : java.lang.IllegalArgumentException: Key must be integer You are applying get to a real collection. map takes a function to be applied to each element. For example, #(get % 1). More idiomatic: (map second xs). cheers lvh oke, and second could be the helper function. I know what schould be done map has to pick up the items and on that item I have to be doing the get. Roelof -- 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.
Re: map problem (Ilove ponies)
Thanks, but still very confusing for a beginner. the exercise is talking about using a helper function and it looks like second does the same as (get coll 1 ) Roelof Op vrijdag 24 oktober 2014 14:19:28 UTC+2 schreef Laurens Van Houtven: Hi Roelof, On 24 Oct 2014, at 14:16, Roelof Wobben rwo...@hotmail.com javascript: wrote: oke, and second could be the helper function. `second` is part of Clojure. You do not have to write it. I know what schould be done map has to pick up the items and on that item I have to be doing the get. Yes. map calls its first argument with all of the items in the collection. hth lvh -- 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.
Re: map problem (Ilove ponies)
I try to make exercise 16. Roelof Op vrijdag 24 oktober 2014 14:27:19 UTC+2 schreef Laurens Van Houtven: Hi Roelof, I had no idea iloveponies was a Clojure introduction. https://iloveponies.github.io/120-hour-epic-sax-marathon/structured-data.html What exercise are you attempting, exactly? cheers lvh -- 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.
Re: map problem (Ilove ponies)
Yes. I solved the problem with : (defn second-elements [collection] (let [second-item (fn [x] (get x 1))] (map second-item collection))) one thing I m not sure I understand complete. x is the output of the map command, if so, how does Clojure know that. Roelof Op vrijdag 24 oktober 2014 14:45:20 UTC+2 schreef Laurens Van Houtven: Hi Roelof, OK, so, what you want to do is look at the example right before it, (defn mungefy …). You want to do something very similar: except instead of munge you’ll have a different (fn [x] …) that uses get on x. Make sense? hth lvh -- 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.
Re: map problem (Ilove ponies)
Op vrijdag 24 oktober 2014 15:32:33 UTC+2 schreef Laurens Van Houtven: Hi Roelof, On 24 Oct 2014, at 15:12, Roelof Wobben rwo...@hotmail.com javascript: wrote: I understand that part but when I look at the map part there is no x. When I look at the function no x. I’m assuming you mean that when you look at the function, you do see the x — it’s right there, both in the argument list and in the body. So how does Clojure know what the value of x is. Then you haven’t quite understood it ;-) Consider: (defn double [x] (* x 2)) i.e. a function that doubles its argument. When you call (double 4), how does Clojure “know” what x is? The same way that you call double with 4, map applies the function you pass it to each element of the collection you pass it. So, for example: (map double [3 5 7]) will basically do [(double 3) (double 5) (double 7)]. The “x” is “replaced”, if you will, just like it is with regular function application. That’s all map is: a bunch of function applications and tying the results together :-) *(except that it actually returns a lazy seq, not a vector, but that’s besides the point here). hth lvh I understand that part. so we have (map second-item collection) where second-item and collection are arguments of map. Then we have second-item ( fn [x] (get x 2) which can be read as : ( second-item [x] (get x 2) . in the map there is only ( map second-item collection) or is the collection a argument of second-item and a argument of map. Roelof -- 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.
Re: map problem (Ilove ponies)
Sorry but I still do not have a clue how clojure knows what x is. the first part where x is mentioned is the fn part and on the map part there is no mention about x. Roelof Op vrijdag 24 oktober 2014 15:51:30 UTC+2 schreef Laurens Van Houtven: Hi Roelof, I understand that part. so we have (map second-item collection) where second-item and collection are arguments of map. Yep. Then we have second-item ( fn [x] (get x 2) which can be read as : ( second-item [x] (get x 2) . This makes no sense to me. second-item is a fn. In this syntax, (malformed because of a missing closing bracket), you are calling second-item with [x] and (get x 2), without having defined x. in the map there is only ( map second-item collection) or is the collection a argument of second-item and a argument of map. No. second-item and collections are the arguments of map. map will call second-item for each element in coll. map’s job is to “pull apart” the collection, element by element, pass it to f, and give you the result back. hth lvh -- 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.
Re: map problem (Ilove ponies)
oke, So map is taking the first item of coll and put's it in x. Then it calling second-item . Now I understand . Thanks a lot for the patience and explanation. Roelof Op vrijdag 24 oktober 2014 16:01:48 UTC+2 schreef Laurens Van Houtven: (defn double [x] (* x 2)) See, x is right there ^ Now, I do (double 10). How does Clojure “know what the x is”? There’s no x in that expression. Exactly the same with map. The x is just a name; it doesn’t matter what it is. The only thing that matters is that you call that function (whether it’s double or second-item or whatever) with a single argument. In (double 10), I’m calling it with 10. In (map second-item coll), map is calling second-item with each of the items in coll. These are exactly the same thing: in both cases it’s just function application. hth lvh On 24 Oct 2014, at 15:56, Roelof Wobben rwo...@hotmail.com javascript: wrote: Sorry but I still do not have a clue how clojure knows what x is. the first part where x is mentioned is the fn part and on the map part there is no mention about x. Roelof Op vrijdag 24 oktober 2014 15:51:30 UTC+2 schreef Laurens Van Houtven: Hi Roelof, I understand that part. so we have (map second-item collection) where second-item and collection are arguments of map. Yep. Then we have second-item ( fn [x] (get x 2) which can be read as : ( second-item [x] (get x 2) . This makes no sense to me. second-item is a fn. In this syntax, (malformed because of a missing closing bracket), you are calling second-item with [x] and (get x 2), without having defined x. in the map there is only ( map second-item collection) or is the collection a argument of second-item and a argument of map. No. second-item and collections are the arguments of map. map will call second-item for each element in coll. map’s job is to “pull apart” the collection, element by element, pass it to f, and give you the result back. hth lvh -- 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 javascript: 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 javascript: 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+u...@googlegroups.com javascript:. 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.
how to count items in a list
Hello, Im at exercise 21 : http://iloveponies.github.io/120-hour-epic-sax-marathon/structured-data.html#exercise-20 Where I have to find out if a sequence has duplicates. But I have no clue how to handle this . I think making a set of it and then map count the old one with the set I have made. Then I have made a new sequence with all the counts and have to check if there is a number higher then 1 in the sequence. But this seems to be a way with a lot of steps. Is there a better way for a beginner ? Roelof -- 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.
midje test : Can I only run 1 test
Hello, I try again to learn clojure by the ponies github pages. But sometimes there is a lot of output of midje. Can I run only 1 test ? Roelof -- 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.
book for a beginner with some exercises
Hello, Is there a book for a beginner in Clojure where I can learn things and practice the things I learned with some exercises ? Roelof -- 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.
count not supported on this type
I try to make this assigment : Write the function (contains-duplicates? sequence) that takes a sequence as a parameter and returns true if sequence contains some element multiple times. Otherwise it returns false. So I did this : (defn contains-duplicates? [a-seq] (let [element (fn element [a-seq] (count a-seq) )] (= (map element a-seq)1))) But then I see this message : UnsupportedOperationException count not supported on this type: Long clojure.lang.RT.countFrom (RT.java:556) When I change map to apply I see this message : ArityException Wrong number of args (5) passed to: structured-data$contains-duplicates-QMARK-$element clojure.lang.AFn.throwArity (AFn.java:437) Where did I misunderstood this page : http://iloveponies.github.io/120-hour-epic-sax-marathon/structured-data.html Roelof -- 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.
Re: count not supported on this type
oke, Then I have to fnd another way to see how many times a number is present in a collection. I thought count could do that. Roelof Op vrijdag 9 mei 2014 20:24:29 UTC+2 schreef James Reeves: Your function is essentially: (= (map count coll) 1) So you're applying the function count to each element in the collection. Let's say your collection is: [1 2 3] Then you're trying to evaluate: [(count 1) (count 2) (count 3)] Clojure is raising an exception that says I can't count a number, I can only count collections. - James On 9 May 2014 17:42, Roelof Wobben rwo...@hotmail.com javascript:wrote: I try to make this assigment : Write the function (contains-duplicates? sequence) that takes a sequence as a parameter and returns true if sequence contains some element multiple times. Otherwise it returns false. So I did this : (defn contains-duplicates? [a-seq] (let [element (fn element [a-seq] (count a-seq) )] (= (map element a-seq)1))) But then I see this message : UnsupportedOperationException count not supported on this type: Long clojure.lang.RT.countFrom (RT.java:556) When I change map to apply I see this message : ArityException Wrong number of args (5) passed to: structured-data$contains-duplicates-QMARK-$element clojure.lang.AFn.throwArity (AFn.java:437) Where did I misunderstood this page : http://iloveponies.github.io/120-hour-epic-sax-marathon/structured-data.html Roelof -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 javascript: 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+u...@googlegroups.com javascript:. 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.
CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur
Hello, I have this form (ns forclojure.core) (defn secondlast [coll counter] (let [ number 0 counter ( - (count coll)2)] (loop [coll counter] (if (== counter number) (first coll) (recur (next coll) (+ counter 1 )) But as soon as I try to send it to REPL I see this message: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 1 args, got: 2, compiling:(/home/roelof/clojure/forclojure/src/forclojure/core.clj:9:11) Roelof -- 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.
Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur
Op dinsdag 6 mei 2014 10:43:40 UTC+2 schreef Benjamin R. Haskell: `loop` expects a vector of binding forms (with initial values), not just a vector of names. (loop [coll counter]; means there is one `loop` binding named `coll`, with the initial value of `counter` To fix that problem directly: (loop [collcoll ; coll starts with an initial value of its value outside the loop counter counter] ; counter starts with an initial value of its value outside the loop ;; rest of code here ... Then you're left with an extra `let` (which was serving a similar purpose to `loop` initialization?), and the whole `loop` is possibly superfluous, because a function can be the target of a `recur`. oke, so I could do (loop [ coll coll counter 0] instead of the let ? And what do you mean with superfluous ?? Roelof -- 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.
Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur
I changed everything to this : (ns forclojure.core) (defn secondlast [coll] (let [number 0 ] (loop [coll coll counter (- (count coll)2)] (if (== counter number) (first coll) (recur (next coll) (+ number 1)) But now I get a loop which never ends. Roelof Op dinsdag 6 mei 2014 10:51:09 UTC+2 schreef Roelof Wobben: Op dinsdag 6 mei 2014 10:43:40 UTC+2 schreef Benjamin R. Haskell: `loop` expects a vector of binding forms (with initial values), not just a vector of names. (loop [coll counter]; means there is one `loop` binding named `coll`, with the initial value of `counter` To fix that problem directly: (loop [collcoll ; coll starts with an initial value of its value outside the loop counter counter] ; counter starts with an initial value of its value outside the loop ;; rest of code here ... Then you're left with an extra `let` (which was serving a similar purpose to `loop` initialization?), and the whole `loop` is possibly superfluous, because a function can be the target of a `recur`. oke, so I could do (loop [ coll coll counter 0] instead of the let ? And what do you mean with superfluous ?? Roelof -- 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.
Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur
Op dinsdag 6 mei 2014 12:40:24 UTC+2 schreef James Reeves: Well, == should be =, but more importantly you're mixing up number and counter. Step through your code one bit at a time: 1. You set number to 0 2. You set counter to (count coll) - 2 3. If number and counter are not equal... 4. Recur with the next part of the list, and set the counter to (+ number 1) See how you've got counter and number mixed up? Yep, So I change it to this : (defn secondlast [coll] (let [number 0 ] (loop [coll coll counter (- (count coll)2)] (if (= counter number) (first coll) (recur (next coll) (+ number 1)) But when I do (secondlast (list 1 2 3 4 5)) I still do not get a answer, Roelof - James On 6 May 2014 11:24, Roelof Wobben rwo...@hotmail.com javascript:wrote: I changed everything to this : (ns forclojure.core) (defn secondlast [coll] (let [number 0 ] (loop [coll coll counter (- (count coll)2)] (if (== counter number) (first coll) (recur (next coll) (+ number 1)) But now I get a loop which never ends. Roelof Op dinsdag 6 mei 2014 10:51:09 UTC+2 schreef Roelof Wobben: Op dinsdag 6 mei 2014 10:43:40 UTC+2 schreef Benjamin R. Haskell: `loop` expects a vector of binding forms (with initial values), not just a vector of names. (loop [coll counter]; means there is one `loop` binding named `coll`, with the initial value of `counter` To fix that problem directly: (loop [collcoll ; coll starts with an initial value of its value outside the loop counter counter] ; counter starts with an initial value of its value outside the loop ;; rest of code here ... Then you're left with an extra `let` (which was serving a similar purpose to `loop` initialization?), and the whole `loop` is possibly superfluous, because a function can be the target of a `recur`. oke, so I could do (loop [ coll coll counter 0] instead of the let ? And what do you mean with superfluous ?? Roelof -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 javascript: 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+u...@googlegroups.com javascript:. 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.
Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur
As far as I understand recur is going back to the loop so number is never going back to 0 but I see the problem (-(count coll)2 is changing it value and that schould not happen. So I think I have to set the initial value of counter in the let. what schould happen is this collnumbercounter 1) [1,2,3.4.5) 0 3 2) [2.3,4,5]1 3 3) [3,4,5] 2 3 4) [ 4,5] 3 3 so the (first coll) is executed which is 4. Am I at the right track now. Roelof -- 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.
Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur
Found the answer : (defn secondlast [coll] (let [number 0 counter (- (count coll)2) ] (loop [coll coll counter counter number number] (if (= counter number) (first coll) (recur (next coll) counter (+ number 1)) and without the loop there will be : (first(drop(reverse v)) Roelof Op dinsdag 6 mei 2014 13:36:53 UTC+2 schreef Roelof Wobben: As far as I understand recur is going back to the loop so number is never going back to 0 but I see the problem (-(count coll)2 is changing it value and that schould not happen. So I think I have to set the initial value of counter in the let. what schould happen is this collnumbercounter 1) [1,2,3.4.5) 0 3 2) [2.3,4,5]1 3 3) [3,4,5] 2 3 4) [ 4,5] 3 3 so the (first coll) is executed which is 4. Am I at the right track now. Roelof -- 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.
Re: find the last and the nth item without using last or nth
I tried this problem again. So I did this: (defn nth* [coll, number] (let [acc 0] (loop [coll coll acc] (if == acc number)) (first coll) (recur (next coll) (+acc 1 )) but when I do : (nth* (1,2,3,4,5)2)) I see a cannot cast error message. Is this because Clojure cannot figure out what the coll and what the number is ? Roelof Op woensdag 30 april 2014 12:53:01 UTC+2 schreef James Reeves: On 30 April 2014 11:41, Roelof Wobben rwo...@hotmail.com javascript:wrote: Op woensdag 30 april 2014 12:14:39 UTC+2 schreef James Reeves: Consider how you might add a counter to the loop. You'll want to increment the counter, then stop when it reaches the desired number. So without checking it so out of my head I would do this (defn last* [coll, number] (loop [coll coll] (if == counter number)) (first coll) (recur (next coll) (+counter 1 )) Essentially yes. You need to initiate the counter to zero, and you still need a condition to make sure you don't go past the end of the seq (in case n is more than the length of the list), but you've basically got it. - James -- 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.
Re: find the last and the nth item without using last or nth
Thanks, Roelof Op dinsdag 6 mei 2014 17:11:52 UTC+2 schreef James Reeves: You have a number of typos, syntax errors and missing brackets in your source code. It should be: (defn nth* [coll number] (loop [coll coll, acc 0] (if (= acc number) (first coll) (recur (next coll) (+ acc 1) Additionally, you're using an unquoted list to test. Use a vector or quote the list: (nth* [1 2 3 4 5] 2) - James On 6 May 2014 16:05, Roelof Wobben rwo...@hotmail.com javascript:wrote: I tried this problem again. So I did this: (defn nth* [coll, number] (let [acc 0] (loop [coll coll acc] (if == acc number)) (first coll) (recur (next coll) (+acc 1 )) but when I do : (nth* (1,2,3,4,5)2)) I see a cannot cast error message. Is this because Clojure cannot figure out what the coll and what the number is ? Roelof Op woensdag 30 april 2014 12:53:01 UTC+2 schreef James Reeves: On 30 April 2014 11:41, Roelof Wobben rwo...@hotmail.com wrote: Op woensdag 30 april 2014 12:14:39 UTC+2 schreef James Reeves: Consider how you might add a counter to the loop. You'll want to increment the counter, then stop when it reaches the desired number. So without checking it so out of my head I would do this (defn last* [coll, number] (loop [coll coll] (if == counter number)) (first coll) (recur (next coll) (+counter 1 )) Essentially yes. You need to initiate the counter to zero, and you still need a condition to make sure you don't go past the end of the seq (in case n is more than the length of the list), but you've basically got it. - James -- 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.
why is this failing on a list
Hello, For 4clojure I have to find the second to last item. So I did this: (fn secondlast [v] (get v (-(count v)1))) Now it's only failing at this test : (= (__ (list 1 2 3 4 5)) 4) Can anyone tell me where I did take the wrong way. Roelof -- 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.
Re: why is this failing on a list
oke, Then I think I have to work with a if then : The second test is already a vector but the thirth not (= (__ [a b c]) b) (= (__ [[1 2] [3 4]]) [1 2]) I tried already the nth but I was also failing on the first. I think because of count because you cannot know how many values you have. (fn secondlast [v] (nth v (-(count v)1))) Roelof Op zondag 4 mei 2014 16:49:45 UTC+2 schreef Lee: On May 4, 2014, at 10:42 AM, Roelof Wobben rwo...@hotmail.comjavascript: wrote: For 4clojure I have to find the second to last item. So I did this: (fn secondlast [v] (get v (-(count v)1))) Now it's only failing at this test : (= (__ (list 1 2 3 4 5)) 4) Can anyone tell me where I did take the wrong way. The get function with integer keys works for vectors but not for lists: = (get [7 8 9] 1) 8 = (get '(7 8 9) 1) nil So one option would be to call vec on the list before calling get: = (get (vec '(7 8 9)) 1) 8 Another option would be to use nth instead of get. -Lee -- 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.
Do not understand why loop takes 3 arguments who are all the same
Hello, Im now at the last exercise of the beginners exercise of 4clojure. I figured out that this solution works. (fn [default lijst1] (loop [lijst lijst1 d {}] (if (empty? lijst) d (recur (rest lijst) (assoc d (first lijst) default) But as I see it lijst lijst 1 and d are all the same. They all contains the collection which has to fill in the end collection. As a example I mean default = 0 lijst 1 [:a :b: :c] then lijst1 and d also contains [:a :b:c] so what is then the point of using 3 arguments. Roelof -- 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.
Re: Do not understand why loop takes 3 arguments who are all the same
(fn [default initial-keys] (loop [remaining-keys initial-keys result-map {}] (if (empty? remaining-keys) result-map (let [key (first remaining-keys) remaining-keys' (rest remaining-keys) result-map' (assoc result-map key default)] (recur remaining-keys' result-map') This also passes the unit tests. Maybe that’s a bit clearer as to what’s going on. Maybe the new names help a bit. Notice the ticks on some of the names (the ‘ characters). This is just a convention some programmers use. The ticks are part of the name, nothing magic, and are used to indicate that the value of the name is derived from the value of the name with one less tick. Some programmers use numbers instead. Other programmers don’t care and just use the same name. When you’ve understood the solution you’ve come up with, you might want to try using reduce to do this. It’ll be both shorter and much easier to understand. If you look carefully at your code the only part that isn’t boiler-plate is the (assoc result-map key default) — the boiler-plate corresponds closely to what reduce does. Thanks, Now It more clearer what loop does. I can look at a reduce solution but then I have to look which reduce I have to use. I know reduce + and reduce - which does calculations on the collection. Roelof -- 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.
Re: Do not understand the - macro here
Is this a nice explanation about macros : http://bryangilbert.com/code/2013/07/30/anatomy-of-a-clojure-macro/ or is there a better one for a beginner. Roelof -- 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.
Re: Do not understand the - macro here
Op donderdag 1 mei 2014 15:20:38 UTC+2 schreef Erlis Vidal: I think the confusion is because they used multiple values when comparing the equality (= (__ (sort (rest (reverse [2 5 4 1 3 6] (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__)) 5) This can be seen as : (def A (__ (sort (rest (reverse [2 5 4 1 3 6]) (def B (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))) Then the 4Clojure exercise can be written as: (= A B 5) Do not feel bad, this took me some time to realize 5 was not part of B. No problem. But still it does not make any sense. If I do it right. this schould be the output of the functions A [ 1 2 3 4 5] B [ 1 2 3 4 5] (= A B 5) -- [1,2,3,4,5] = [1,2,3,4,5] = 5 and this is not true. On Thu, May 1, 2014 at 7:52 AM, Roelof Wobben rwo...@hotmail.comjavascript: wrote: Is this a nice explanation about macros : http://bryangilbert.com/code/2013/07/30/anatomy-of-a-clojure-macro/ or is there a better one for a beginner. Roelof -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 javascript: 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+u...@googlegroups.com javascript:. 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.
Re: Do not understand the - macro here
oke, I misunderstood everyone. The right answer is last. (def A (__ (sort (rest (reverse [2 5 4 1 3 6]) which would be : (def A (last (sort (rest (reverse [2 5 4 1 3 6]) which resolves to 5 (def B (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))) Which would be : (def B (- [2 5 4 1 3 6] (reverse) (rest) (sort) (last))) which resolves also to 5 so the last part : ( = a b 5) is also true ( = 5 5 5) Still I find it wierd to make such sort of form. Roelof Op donderdag 1 mei 2014 16:35:59 UTC+2 schreef Erlis Vidal: Look that (def A ...) won't compile as given, so you cannot say A is [1 2 3 4 5], A is something else once you make it compile filling the blank space with the missing function. On Thu, May 1, 2014 at 10:24 AM, Maik Schünemann maiksch...@gmail.comjavascript: wrote: The task is to replace __ with the function that makes this true in this case makes [1 2 3 4 5] to 5 On Thu, May 1, 2014 at 4:23 PM, Maik Schünemann maiksch...@gmail.comjavascript: wrote: On Thu, May 1, 2014 at 3:51 PM, Roelof Wobben rwo...@hotmail.comjavascript: wrote: Op donderdag 1 mei 2014 15:20:38 UTC+2 schreef Erlis Vidal: I think the confusion is because they used multiple values when comparing the equality (= (__ (sort (rest (reverse [2 5 4 1 3 6] (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__)) 5) This can be seen as : (def A (__ (sort (rest (reverse [2 5 4 1 3 6]) (def B (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))) Then the 4Clojure exercise can be written as: (= A B 5) Do not feel bad, this took me some time to realize 5 was not part of B. No problem. But still it does not make any sense. If I do it right. this schould be the output of the functions A [ 1 2 3 4 5] B [ 1 2 3 4 5] (= A B 5) -- [1,2,3,4,5] = [1,2,3,4,5] = 5 and this is not true. This is the output when you don't write the function to replace __. On Thu, May 1, 2014 at 7:52 AM, Roelof Wobben rwo...@hotmail.comwrote: Is this a nice explanation about macros : http://bryangilbert.com/code/2013/07/30/anatomy-of-a-clojure-macro/ or is there a better one for a beginner. Roelof -- 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 --- 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+u...@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 clo...@googlegroups.comjavascript: 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 javascript: 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+u...@googlegroups.com javascript:. 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 clo...@googlegroups.comjavascript: 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 javascript: 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+u...@googlegroups.com javascript:. 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
find the last and the nth item without using last or nth
Hello, IM busy with 4Clojure and I have now two challenges which I think can be solved the same way. On a list I first have to find the last item of a list without using last and after that I have to do the same for a nth item and im not allowed to use nth. Now I can convert the list to a vector and use the vector things but I think this is cheating at some way. Could a recurvice way or a loop do the trick. And how do I then take the right value. Should I use first then or is there a better way. I also read about doseq but then I have to find out how to print only the item I want. Anyone who can give a hint without spoiling the answer. Roelof -- 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.
Re: find the last and the nth item without using last or nth
Op woensdag 30 april 2014 08:21:40 UTC+2 schreef James Reeves: Your intuition that this can be done through recursion or a loop is correct (the latter being a more specialised version of the former). When dealing with recursion, it often helps to consider the base case, i.e. where the recursion stops. Typically this is when you get to zero or one elements. You may wish to consider the following questions: 1. How do you find the last element of a seq with exactly one element? the last and the first element are the same 2. How do you find out whether a seq has one element, or more than one element? Look at the length of the seq 3. How do you find out the last element if a seq with exactly two elements? take the first element away and you have a seq of one element . 4. How do you find out the last element of a seq that may have one *or* two elements? Look at the length. If it has one element , see question 1 if it has 2 elements, see question 3. - James On 30 April 2014 07:08, Roelof Wobben rwo...@hotmail.com javascript:wrote: Hello, IM busy with 4Clojure and I have now two challenges which I think can be solved the same way. On a list I first have to find the last item of a list without using last and after that I have to do the same for a nth item and im not allowed to use nth. Now I can convert the list to a vector and use the vector things but I think this is cheating at some way. Could a recurvice way or a loop do the trick. And how do I then take the right value. Should I use first then or is there a better way. I also read about doseq but then I have to find out how to print only the item I want. Anyone who can give a hint without spoiling the answer. Roelof -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 javascript: 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+u...@googlegroups.com javascript:. 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.
Re: find the last and the nth item without using last or nth
Op woensdag 30 april 2014 08:22:07 UTC+2 schreef Tassilo Horn: Roelof Wobben rwo...@hotmail.com javascript: writes: Could a recurvice way or a loop do the trick. Yes. And how do I then take the right value. For nth, you need a counter that you can increment in each recursion step. For last, you return the first element of the list whose rest is the empty list. Bye, Tassilo Thanks, and if I use cons (item, list) then item is the value I want. I only have to print it. Roelof -- 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.
Re: find the last and the nth item without using last or nth
Op woensdag 30 april 2014 08:50:22 UTC+2 schreef Roelof Wobben: Op woensdag 30 april 2014 08:22:07 UTC+2 schreef Tassilo Horn: Roelof Wobben rwo...@hotmail.com writes: Could a recurvice way or a loop do the trick. Yes. And how do I then take the right value. For nth, you need a counter that you can increment in each recursion step. For last, you return the first element of the list whose rest is the empty list. Bye, Tassilo Thanks, and if I use cons (item, list) then item is the value I want. I only have to print it. Roelof If I look at the documentations I think I have to use doseq for running and cons for finding and a if then to stop at the right place. Am I at the right track. -- 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.
Re: find the last and the nth item without using last or nth
Op woensdag 30 april 2014 09:58:26 UTC+2 schreef James Reeves: On 30 April 2014 07:49, Roelof Wobben rwo...@hotmail.com javascript:wrote: Op woensdag 30 april 2014 08:21:40 UTC+2 schreef James Reeves: 1. How do you find the last element of a seq with exactly one element? the last and the first element are the same Right. So to formalise it: (defn last* [coll] (first coll)) I'm using last* as the name so that it doesn't conflict with the function last in clojure.core. 2. How do you find out whether a seq has one element, or more than one element? Look at the length of the seq Unlike vectors, seqs are simple structures and don't know their own length. You can count seqs, but this involves iterating through every element in turn. If all you want to do is find out whether there is more than one element, there's a much simpler and more efficient way. Yep, if there is only 1 item is a list (rest coll) is nil. In code, this would be: (defn last* [coll] (if (more-than-one-element? coll) (first (rest coll)) (first coll))) The more-than-one-element? to be replaced with the answer to question 2, of course. Can you think of a way of making this function recursive to work with any number of elements? I think I can but I have to try some things but untested it looks like this (defn last* [coll] (if (nil? (rest coll) (first coll))) (last* (rest coll)) Now I wonder how I can make it work if I want to find lets say the 5th value of a array of any number of elements Then rest is never nil. So at first glance if I do not know the length it cannnot be done recursive. I have to do it in a for loop. - James -- 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.
Re: find the last and the nth item without using last or nth
Op woensdag 30 april 2014 09:58:26 UTC+2 schreef James Reeves: On 30 April 2014 07:49, Roelof Wobben rwo...@hotmail.com javascript:wrote: Op woensdag 30 april 2014 08:21:40 UTC+2 schreef James Reeves: 1. How do you find the last element of a seq with exactly one element? the last and the first element are the same Right. So to formalise it: (defn last* [coll] (first coll)) I'm using last* as the name so that it doesn't conflict with the function last in clojure.core. 2. How do you find out whether a seq has one element, or more than one element? Look at the length of the seq Unlike vectors, seqs are simple structures and don't know their own length. You can count seqs, but this involves iterating through every element in turn. If all you want to do is find out whether there is more than one element, there's a much simpler and more efficient way Yes , with only 1 item (res col) is nill. -- 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.
Re: find the last and the nth item without using last or nth
Op woensdag 30 april 2014 12:14:39 UTC+2 schreef James Reeves: On 30 April 2014 10:41, Roelof Wobben rwo...@hotmail.com javascript:wrote: Op woensdag 30 april 2014 09:58:26 UTC+2 schreef James Reeves: Unlike vectors, seqs are simple structures and don't know their own length. You can count seqs, but this involves iterating through every element in turn. If all you want to do is find out whether there is more than one element, there's a much simpler and more efficient way. Yep, if there is only 1 item is a list (rest coll) is nil. Almost. Clojure distinguishes between nil and the empty list. The function you want is next: (rest [1]) = () (next [1]) = nil Why the distinction between next and rest? It has to do with laziness, and if you're interested I can go into more detail. Otherwise just remember that rest returns an empty list, and next returns nil. (defn last* [coll] (loop [coll coll] (if (nil? (next coll)) (first coll) (recur (next coll Consider how you might add a counter to the loop. You'll want to increment the counter, then stop when it reaches the desired number. So without checking it so out of my head I would do this (defn last* [coll, number] (loop [coll coll] (if == counter number)) (first coll) (recur (next coll) (+counter 1 )) -- 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.
Do not understand the - macro here
On 4 clojure there it this exercise: (= (__ (sort (rest (reverse [2 5 4 1 3 6] (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__)) 5) if I understand it right this is happen reverse[ 2 5 4 1 3 6] gives [ 6 3 1 4 5 2 ] Then rest [ 6 3 1 4 5 2] gives [ 3 1 4 5 2] Sort this and you get [ 1 2 3 4 5] This part : [2 5 4 1 3 6] (reverse) (rest) (sort) gives the same output: [ 1 2 3 4 5] what does the (__)) 5) does exactly. When I change the 5 to another number the outcome is not changed. And where does clojure put the first [ 1 2 3 4 5 ] in the second form ? Roelof -- 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.
Re: Do not understand the - macro here
Op woensdag 30 april 2014 18:46:36 UTC+2 schreef James Reeves: These two forms are equivalent: (__ (sort (rest (reverse [2 5 4 1 3 6] (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__)) The - macro turns the second form into the first. You can see this by running macroexpand-all: (require '[clojure.walk :refer [macroexpand-all]]) (macroexpand-all '(- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))) This should produce: (__ (sort (rest (reverse [2 5 4 1 3 6] - James That what I expected. what is the benefit of this if the first forms already gives the right answer. The only thing I still do not see is what the 5) is doing here. It looks to me of writing something very difficult where it could be done very easy with just the first form. Roelof -- 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.
Re: Do not understand the - macro here
Op woensdag 30 april 2014 19:12:24 UTC+2 schreef James Reeves: The 5 is just the last part of the equality statement. This might be easier to see by adding in a let: (let [x (__ (sort (rest (reverse [2 5 4 1 3 6] y (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))] (= x y 5)) - James Sorry I still do not see it If I understand it right it will be like this (let [x (__ [ 1 2 3 4 5] y (- [ 1 2 3 4 5] (= [1 2 3 4 5] [ 1 2 3 4 5] 5)) it still looks very wierd to me Roelof -- 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.
Re: Do not understand the - macro here
Op woensdag 30 april 2014 19:46:41 UTC+2 schreef James Reeves: The __ needs to be replaced with a function. So essentially it boils down to: (= (__ [1 2 3 4 5]) 5) What function when called with [1 2 3 4 5] returns 5? - James Thats a easy one . That is last. But what I try to find out and do not understand is how it boils down to that question. Why make a difficult thing if you could also write down the question that you have asked. Roelof On 30 April 2014 18:18, Roelof Wobben rwo...@hotmail.com javascript:wrote: Op woensdag 30 april 2014 19:12:24 UTC+2 schreef James Reeves: The 5 is just the last part of the equality statement. This might be easier to see by adding in a let: (let [x (__ (sort (rest (reverse [2 5 4 1 3 6] y (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))] (= x y 5)) - James Sorry I still do not see it If I understand it right it will be like this (let [x (__ [ 1 2 3 4 5] y (- [ 1 2 3 4 5] (= [1 2 3 4 5] [ 1 2 3 4 5] 5)) it still looks very wierd to me Roelof -- 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.
cursive plugin question
Hello, I installed intelij with the cursive plugin. Now I wonder if this can be done in some way. Suppose I have a file with 3 functions. Can I send one to REPL so I can test if it works as I expected. Roelof -- 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.
eclipse REPL problem (no prompt)
Hello, I try now the eclipse with CounterClockwise plugin. It looks to work fine except one thing. When I open a repl I do not see a sort of prompt. Does anyone know how to solve this ? Roelof -- 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.
Re: Which linux distro has intelij ?
Thanks all for the remarks. Im now looking at codebox.io. The only thing I did not find so far is repl. The rest seems to be avaible. Roelof Op woensdag 23 april 2014 07:07:58 UTC+2 schreef Ruslan Prokopchuk: Arch has one always up to date. вторник, 22 апреля 2014 г., 21:11:54 UTC+4 пользователь Roelof Wobben написал: Hello, Does anyone know a Linux distro which I can use to learn clojure and which has inteljij aviable. I really like to test the cursive plugin Roelof -- 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.
comparison with 3 arguments. Do I understand it right ?
Hello, I do not understand why this work. I have to check if someone is between 12 and 20 years. So after some trail and error this seems to work (defn teen? [age] (if ( 12 age 20) true; false)) Is it right it stated 12 age 20 ? Roelof -- 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.
Re: comparison with 3 arguments. Do I understand it right ?
Thanks, But something is not going right. When delete the if as you said and have this : (defn boolean [x] (or (false? x)(nil? x)) false; true) (defn abs [x] ( x 0) (* x -1); x) (defn teen? [age] ( 12 age 20) true; false) Then all tests fail and if I put a if before it , they all work well. Roelof Op woensdag 23 april 2014 12:19:01 UTC+2 schreef James Reeves: ( a b c) is equivalent to (and ( a b) ( b c)), so yes, ( 12 age 20) is the same as 12 age 20. You could write your function more concisely as: (defn teen? [age] ( 12 age 20)) The if statement is unnecessary. - James On 23 April 2014 11:11, Roelof Wobben rwo...@hotmail.com javascript:wrote: Hello, I do not understand why this work. I have to check if someone is between 12 and 20 years. So after some trail and error this seems to work (defn teen? [age] (if ( 12 age 20) true; false)) Is it right it stated 12 age 20 ? Roelof -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 javascript: 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+u...@googlegroups.com javascript:. 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.
Re: comparison with 3 arguments. Do I understand it right ?
Op woensdag 23 april 2014 13:23:17 UTC+2 schreef David Della Costa: What James meant was that you should use it like so: = (defn teen? [age] ( 12 age 20)) #'user/teen? = (teen? 50) false = (teen? 10) false = (teen? 14) true = (if (teen? 14) yes is a teen no, not a teen) yes is a teen You don't need to set up these wrappers returning true and false. nil and false are false in Clojure, everything else is true. Remember that and you'll be good to go. DD Thanks, The only thing which is failing now is this one ; (defn abs [x] ( x 0) (* x -1); x) I keep getting -2 as answer where it must be 2 Roelof -- 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.
Re: comparison with 3 arguments. Do I understand it right ?
Op woensdag 23 april 2014 14:26:14 UTC+2 schreef Tassilo Horn: Roelof Wobben rwo...@hotmail.com javascript: writes: The only thing which is failing now is this one ; (defn abs [x] ( x 0) (* x -1); x) I keep getting -2 as answer where it must be 2 Well, the function contains three forms where the results of the first two are ignored and only the value of the last one is returned. So here you need an `if`. (defn abs [x] (if ( x 0) (* x -1) x)) Bye, Tassilo BTW: Why do you have those semicolons in your code? That ends a statement in C-like languages but in Lisps including Clojure it starts a comment spanning till the end of the line. oke, So if I understand everything well when I want true or false I do not need a if . In all other cases I need a if. Regarding the ; I thought I was a divider between the then and the else Roelof -- 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.
Re: comparison with 3 arguments. Do I understand it right ?
Chips I thought I understand it But this does not work (defn divides? [divisor n] (mod n divisor)) I still get a cannot be cast error message. Roelof Op woensdag 23 april 2014 14:32:41 UTC+2 schreef Roelof Wobben: Op woensdag 23 april 2014 14:26:14 UTC+2 schreef Tassilo Horn: Roelof Wobben rwo...@hotmail.com writes: The only thing which is failing now is this one ; (defn abs [x] ( x 0) (* x -1); x) I keep getting -2 as answer where it must be 2 Well, the function contains three forms where the results of the first two are ignored and only the value of the last one is returned. So here you need an `if`. (defn abs [x] (if ( x 0) (* x -1) x)) Bye, Tassilo BTW: Why do you have those semicolons in your code? That ends a statement in C-like languages but in Lisps including Clojure it starts a comment spanning till the end of the line. oke, So if I understand everything well when I want true or false I do not need a if . In all other cases I need a if. Regarding the ; I thought I was a divider between the then and the else Roelof -- 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.
Re: comparison with 3 arguments. Do I understand it right ?
Op woensdag 23 april 2014 14:55:39 UTC+2 schreef Tassilo Horn: Roelof Wobben rwo...@hotmail.com javascript: writes: Chips I thought I understand it But this does not work (defn divides? [divisor n] (mod n divisor)) It seems that `divides?` should be a predicate but your definition returns a number and no boolean. A number n is divisible by some divisor if the result of `mod` is zero. That is, you want (defn divides? [divisor n] (zero? (mod n divisor))) Bye, Tassilo Thanks, Now hopefully I can figure out how to output a boolean. Roelof -- 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.
Re: comparison with 3 arguments. Do I understand it right ?
found the solution: (defn divides? [divisor n] (zero? (mod n divisor))) Roelof Op woensdag 23 april 2014 14:59:31 UTC+2 schreef Roelof Wobben: Op woensdag 23 april 2014 14:55:39 UTC+2 schreef Tassilo Horn: Roelof Wobben rwo...@hotmail.com writes: Chips I thought I understand it But this does not work (defn divides? [divisor n] (mod n divisor)) It seems that `divides?` should be a predicate but your definition returns a number and no boolean. A number n is divisible by some divisor if the result of `mod` is zero. That is, you want (defn divides? [divisor n] (zero? (mod n divisor))) Bye, Tassilo Thanks, Now hopefully I can figure out how to output a boolean. Roelof -- 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.
Which linux distro has intelij ?
Hello, Does anyone know a Linux distro which I can use to learn clojure and which has inteljij aviable. I really like to test the cursive plugin Roelof -- 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.
boolean problem
Hello, IM working at the Iloveponies github tutorial and Im stuck here, I have to check if x is a nil or false and then the output must be false,\ Otherwise I have to be true. So I tried this : (defn boolean [x] (if (and (nil? x) (false? x)) ) But then I see a very long error message: xception in thread main java.lang.RuntimeException: EOF while reading, starting at line 4, compiling:(i_am_a_horse_in_the_land_of_booleans.clj:30:1) at clojure.lang.Compiler.load(Compiler.java:7071) at clojure.lang.RT.loadResourceScript(RT.java:370) at clojure.lang.RT.loadResourceScript(RT.java:361) at clojure.lang.RT.load(RT.java:440) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5018.invoke(core.clj:5530) at clojure.core$load.doInvoke(core.clj:5529) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5336) at clojure.core$load_lib$fn__4967.invoke(core.clj:5375) at clojure.core$load_lib.doInvoke(core.clj:5374) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:619) at clojure.core$load_libs.doInvoke(core.clj:5413) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:621) at clojure.core$use.doInvoke(core.clj:5507) at clojure.lang.RestFn.invoke(RestFn.java:421) at iloveponies.tests.i_am_a_horse_in_the_land_of_booleans$eval6263$loading__4910__auto6264.invoke(i_am_a_horse_in_the_land_of_booleans.clj:1) at iloveponies.tests.i_am_a_horse_in_the_land_of_booleans$eval6263.invoke(i_am_a_horse_in_the_land_of_booleans.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6619) at clojure.lang.Compiler.eval(Compiler.java:6608) at clojure.lang.Compiler.load(Compiler.java:7064) at clojure.lang.RT.loadResourceScript(RT.java:370) at clojure.lang.RT.loadResourceScript(RT.java:361) at clojure.lang.RT.load(RT.java:440) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5018.invoke(core.clj:5530) at clojure.core$load.doInvoke(core.clj:5529) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5336) at clojure.core$load_lib$fn__4967.invoke(core.clj:5375) at clojure.core$load_lib.doInvoke(core.clj:5374) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:619) at clojure.core$load_libs.doInvoke(core.clj:5413) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:621) at clojure.core$use.doInvoke(core.clj:5507) at clojure.lang.RestFn.invoke(RestFn.java:408) at i_am_a_horse_in_the_land_of_booleans_test$eval6257$loading__4910__auto6258.invoke(i_am_a_horse_in_the_land_of_booleans_test.clj:1) at i_am_a_horse_in_the_land_of_booleans_test$eval6257.invoke(i_am_a_horse_in_the_land_of_booleans_test.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6619) at clojure.lang.Compiler.eval(Compiler.java:6608) at clojure.lang.Compiler.load(Compiler.java:7064) at clojure.lang.RT.loadResourceScript(RT.java:370) at clojure.lang.RT.loadResourceScript(RT.java:361) at clojure.lang.RT.load(RT.java:440) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5018.invoke(core.clj:5530) at clojure.core$load.doInvoke(core.clj:5529) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5336) at clojure.core$load_lib$fn__4967.invoke(core.clj:5375) at clojure.core$load_lib.doInvoke(core.clj:5374) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:619) at clojure.core$load_libs.doInvoke(core.clj:5413) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:619) at clojure.core$require.doInvoke(core.clj:5496) at clojure.lang.RestFn.invoke(RestFn.java:421) at midje.repl$load_facts$fn__6191.invoke(repl.clj:206) at midje.repl$load_facts.doInvoke(repl.clj:192) at clojure.lang.RestFn.invoke(RestFn.java:397) at user$eval6253.invoke(form-init263954278555209649.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6619) at clojure.lang.Compiler.eval(Compiler.java:6609) at clojure.lang.Compiler.load(Compiler.java:7064) at clojure.lang.Compiler.loadFile(Compiler.java:7020) at clojure.main$load_script.invoke(main.clj:294) at clojure.main$init_opt.invoke(main.clj:299) at clojure.main$initialize.invoke(main.clj:327) at clojure.main$null_opt.invoke(main.clj:362) at clojure.main$main.doInvoke(main.clj:440) at
Re: boolean problem
Op donderdag 17 april 2014 09:34:52 UTC+2 schreef Tassilo Horn: Stanislas Nanchen stanisla...@gmail.com javascript: writes: You miss one parentheses at the end of your expression (defn boolean [x] (if (and (nil? x) (false? x)) )) And now you have an if without then which will give you another exception. And the test expression is a contradiction, i.e., it's always false. Nothing can be both nil? and false?. You are right. Stupid thinking error of me. I have to check if x is a nil or false and then the output must be false,\ Otherwise I have to be true. Why? nil and false are already falsy, everything else is true. And if you have to interact with java where some method wants some real boolean, then there's already clojure.core/boolean. In this exercise you are not allowed to use boolean. Roelof Bye, Tassilo -- 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.
Re: Light table
Thanks all. Unfortunally I cannot get Lighttable work. I work with Nixos where all the packages are stored in /var/store/nixos/hash instead of the way linux does these things. So untill I find out how to compile it from source no Light Table for me. Roelof Op donderdag 17 april 2014 10:34:58 UTC+2 schreef Walter van der Laan: I recently moved from Emacs to Light Table for Clojurescript and I like working with it. I created a tutorial that outlines my Clojurescript workflow using Light Table: github.com/wvdlaan/todomvc For my work on the JVM I still use Emacs because old habits die hard. But I expect to move to Light Table at some point. On Wednesday, April 16, 2014 9:42:40 PM UTC+2, Roelof Wobben wrote: Has anyone tried Light table as a IDE instead of Emacs ? Roelof -- 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.
Re: boolean problem
Op donderdag 17 april 2014 13:26:35 UTC+2 schreef Michael Gardner: On Apr 17, 2014, at 02:34 , Tassilo Horn ts...@gnu.org javascript: wrote: And now you have an if without then which will give you another exception. Yep, but that one I solved already. Not true. It's more common to use 'when', but single-branch ifs are perfectly fine. -- 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.
Re: Light table
It seems that Nightcode works What do you experts think of this IDE. Roelof Op donderdag 17 april 2014 13:39:31 UTC+2 schreef Roelof Wobben: Thanks all. Unfortunally I cannot get Lighttable work. I work with Nixos where all the packages are stored in /var/store/nixos/hash instead of the way linux does these things. So untill I find out how to compile it from source no Light Table for me. Roelof Op donderdag 17 april 2014 10:34:58 UTC+2 schreef Walter van der Laan: I recently moved from Emacs to Light Table for Clojurescript and I like working with it. I created a tutorial that outlines my Clojurescript workflow using Light Table: github.com/wvdlaan/todomvc For my work on the JVM I still use Emacs because old habits die hard. But I expect to move to Light Table at some point. On Wednesday, April 16, 2014 9:42:40 PM UTC+2, Roelof Wobben wrote: Has anyone tried Light table as a IDE instead of Emacs ? Roelof -- 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.
is there a way I can learn clojure with a lot of exercises
Hello, I like to try clojure. I have little or none programming background but I know I learn the best by reading a piece of text and then do exercises about it so I can check if I really understand it. What is then the best way to proceed ? Roelof -- 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.
Re: is there a way I can learn clojure with a lot of exercises
Thanks, Can this site also be good : http://www.braveclojure.com/ Roelof Op woensdag 16 april 2014 09:07:36 UTC+2 schreef Bruce Wang: Try 4clojure.com On Wed, Apr 16, 2014 at 4:56 PM, Roelof Wobben rwo...@hotmail.comjavascript: wrote: Hello, I like to try clojure. I have little or none programming background but I know I learn the best by reading a piece of text and then do exercises about it so I can check if I really understand it. What is then the best way to proceed ? Roelof -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 javascript: 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+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- simple is good http://brucewang.net http://twitter.com/number5 -- 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.
braveclojure problem ( paste into emacs)
Hello, I try to learn coljure by using this tutorial: http://www.braveclojure.com Im now at point 7 : http://www.braveclojure.com/basic-emacs/ There I must paste a text into emacs. But as far as I know there is no mentioned how I can paste text into emacs. Roelof -- 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.
Re: is there a way I can learn clojure with a lot of exercises
Thanks, At this point Im following the first tutorial. Roelof Op woensdag 16 april 2014 12:45:33 UTC+2 schreef Niels van Klaveren: I suggest read up on Clojure for the Brave and Truehttp://www.braveclojure.comand Clojure from the Ground Uphttp://aphyr.com/posts/301-clojure-from-the-ground-up-welcome, then start on 4clojure's exercises http://www.4clojure.com. I'd recommend it over sites with euler problems, since those are more about finding good algorithms for generic puzzles, while 4clojure gives more insight into Clojure's inner workings and pitfalls. As references use clojure-doc.org for tutorials and clojuredocs.org for core function examples. On Wednesday, April 16, 2014 9:53:06 AM UTC+2, Roelof Wobben wrote: Thanks, Can this site also be good : http://www.braveclojure.com/ Roelof Op woensdag 16 april 2014 09:07:36 UTC+2 schreef Bruce Wang: Try 4clojure.com On Wed, Apr 16, 2014 at 4:56 PM, Roelof Wobben rwo...@hotmail.comwrote: Hello, I like to try clojure. I have little or none programming background but I know I learn the best by reading a piece of text and then do exercises about it so I can check if I really understand it. What is then the best way to proceed ? Roelof -- 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 --- 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+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- simple is good http://brucewang.net http://twitter.com/number5 -- 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.
Re: braveclojure problem ( paste into emacs)
Op woensdag 16 april 2014 12:57:41 UTC+2 schreef Roelof Wobben: Hello, I try to learn coljure by using this tutorial: http://www.braveclojure.com Im now at point 7 : http://www.braveclojure.com/basic-emacs/ There I must paste a text into emacs. But as far as I know there is no mentioned how I can paste text into emacs. Roelof -- 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.
Re: braveclojure problem ( paste into emacs)
hello, ctrl-y did the job. Roelof Op woensdag 16 april 2014 13:36:44 UTC+2 schreef Daniel Higginbotham: Sorry for the confusion! As Kashyap mentioned, ctrl-y should work. You can also try your normal keyboard binding for pasting (ctrl-v or cmd-v), that might work as well. Also, if Emacs is too difficult to work with, then it's definitely ok to use whatever editor you like most :) Thanks, Daniel On Wednesday, April 16, 2014 6:57:41 AM UTC-4, Roelof Wobben wrote: Hello, I try to learn coljure by using this tutorial: http://www.braveclojure.com Im now at point 7 : http://www.braveclojure.com/basic-emacs/ There I must paste a text into emacs. But as far as I know there is no mentioned how I can paste text into emacs. Roelof -- 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.
Re: is there a way I can learn clojure with a lot of exercises
Op woensdag 16 april 2014 16:43:09 UTC+2 schreef Charlie Griefer: On Apr 15, 2014, at 11:56 PM, Roelof Wobben rwo...@hotmail.comjavascript: wrote: I like to try clojure. I have little or none programming background but I know I learn the best by reading a piece of text and then do exercises about it so I can check if I really understand it. What is then the best way to proceed ? I know you said that you want to do exercises, but I have to second the recommendations for Clojure for the Brave and True. Great introduction for somebody who has little to no programming background. http://www.braveclojure.com/ Also as others have said, 4Clojure is exactly what you're asking for (exercises). But I'd start off with Clojure for the Brave and True, and as concepts start to click (or maybe even just before that), start working some of the 4Clojure exercises. -- Charlie Griefer http://charlie.griefer.comhttp://charlie.griefer.com Give light, and the darkness will disappear of itself. -- Desiderius Erasmus Thanks, What I do now is read the braveclojure book and do the exercises from http://iloveponies.github.io/120-hour-epic-sax-marathon/index.html So I read a lot and I can see how things work. Roelof -- 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.
Light table
Has anyone tried Light table as a IDE instead of Emacs ? Roelof -- 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.
Do I have to have knowlegde about Lisp
Hello, I like the idea of Clojure but I wonder if I have to know a lot of Lisp to work with Clojure. What is the best way to go from a absolute beginner to someone who can work with Clojure. Roelof -- 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.
Re: Do I have to have knowlegde about Lisp
Op maandag 10 maart 2014 15:41:12 UTC+1 schreef Roelof Wobben: Hello, I like the idea of Clojure but I wonder if I have to know a lot of Lisp to work with Clojure. What is the best way to go from a absolute beginner to someone who can work with Clojure. Roelof -- 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.