This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # beginners (110)
- # boot (50)
- # cider (29)
- # cljs-dev (80)
- # cljsrn (10)
- # clojure (54)
- # clojure-italy (3)
- # clojure-korea (24)
- # clojure-russia (50)
- # clojure-spec (12)
- # clojure-taiwan (1)
- # clojure-uk (67)
- # clojurebridge (14)
- # clojurescript (118)
- # component (3)
- # cursive (11)
- # datomic (28)
- # dirac (31)
- # emacs (45)
- # flambo (2)
- # hoplon (53)
- # immutant (3)
- # jobs (5)
- # mount (8)
- # off-topic (10)
- # om (5)
- # onyx (52)
- # other-languages (2)
- # parinfer (1)
- # pedestal (1)
- # proton (39)
- # protorepl (2)
- # re-frame (22)
- # remote-jobs (1)
- # ring (13)
- # ring-swagger (2)
- # test-check (9)
- # untangled (28)
- # vim (12)
Hi everybody, I made this Atom theme to help me to learn clojure faster because I always make mistakes, then parinfer change a paren without me noticing it. This leads to error messages are often cryptic for a new comers (to say the least) so here you go https://atom.io/packages/clojure-color-scope-syntax http://i.imgur.com/LEilNt1.png
but even with real functions, you should use the
(loop  (recur)) structure because clojure (or rather the JVM) doesnt support tail-call optimization
yeah. compile time . I cant do that. I need to create some helper function to achieve what i want. thanks. @akiroz
It's ok to expand to a call to yourself, just don't actually call yourself in the evaluated parts of the macro
is this a good solution of a recursion exercises of clojure koans :
(defn recursive-reverse [coll] (loop [ coll coll acc () ] (if (empty? coll) acc (recur (rest coll) (conj acc (first coll))))))
That looks good to me. But you can use destructuring for more idiomatic code 🙂
(let [[first & rest ] coll ...])
Heh, yes. You do. You can destructure the
coll in the
let, so you dont need calls to the
first functions 🙂
(defn recursive-reverse [coll] (loop [ [element & the-rest] coll acc '() ] (if-not element acc (recur the-rest (conj acc element)))))
element in my example is the first element of coll. Nil in Clojure is a false'y value, which means, if there are no more elements in coll, element will be nill, which will be evaluated as false.
oke, I do not think I can use it proffessionaly. In the Netherlands almost none clojure jobs
I hope when Im done with the koans and have solved a lot of 4 clojure I can start with making web sites with clojure, @kauko
to get "apples" out of this sentence :
"An Oxford comma list of apples, " can I just do
(last (split " " "An oxford omma list of apples." )) ?
The string argument comes first, and the other argument needs to be a regex. Also you'd usually have clojure.string aliased to str.
(ns foo.core (:require [clojure.string :as str]))
Also you can direct message the clojurebot to test it out without cluttering up the channel
This is the challenge :
"Whether in function definitions" (= (str "An Oxford comma list of apples, " "oranges, " "and pears.") ((fn [[a b c]] __) ["apples" "oranges" "pears"]))
they want you to provide a function that will make the correct string when passed [”apples” “oranges” “pears]
Is there a way I can see what this function produces :
((fn [[a b c]] str("An Oxford list of " a ", " b " and " c "." )) ["apples" "oranges" "pears"])
So then I what do you mean by seeing what the function produces? Just run it at the repl...
That particular funtion will throw an error like java.lang.String cannot be cast to clojure.lang.Ifn
Then I see this error :
ClassCastException java.lang.String cannot be cast to clojure.lang.IFn koan-engine.runner/eval1814/fn--1816 (form-init2907239809023632635.clj:1)
You need to remember that function calls in a lisp are (do-stuff 1 2 3) and not do-stuff(1, 2, 3)
You will see that error message a lot when learning clojure by the way: foo.bar.FooBar cannot be cast to clojure.lang.IFn
oke, I have now this :
(fn [[a b c]] (str "An Oxford list of " a ", " b " and " c "." ) ["apples" "oranges" "pears"]) => #object[koan_engine.runner$eval1886$fn__1888 0x1da0e59 "koan_engine.runner$eval1886$fn__1888@1da0e59"]
You can call it, just put it at the front of a list... The first element of the list is evaluated as a function with the rest of the elements as arguments
haa, but you can easily give it a name! or.. you can call it directly after defining it. like madstap suggested, by putting the outer parens back.
wierd on me :
it still gives no output
((fn [[a b c]] (str "An Oxford list of " a ", " b " and " c "." ) ["apples" "oranges" "pears"]))
You should definitely use paredit, parinfer or something similar though, even though it might feel strange at the start
but I noticed that on repl I have to use one and when I type code I have to use another
maybe later this month Im going to try to run a Linux distro on a usb stick . Then I can test other "ide's "
I tried Sublime Text and it drove me nuts. Weird bugs. Little inconsistencies across Mac, Windows, Linux. And the REPL experience really wasn’t very good.
what do you mean > but I noticed that on repl I have to use one and when I type code I have to use another
I ended up going back to Emacs (after about a 20 year gap) and that’s where I’ve stayed ever since. Well documented, lots of good Clojure configurations (I use Prelude), consistent experience across Mac, Windows, Linux.
@dpsutton i have to use parinfer on the repl but on the code editor I had to use a paredit to make things work
If I have one choosen on repl and I type something the closing ) disappear but if I type with the same on my code part everything works well
and this doesn't happen if you use one mode on the repl and a different mode in code?
@roelofw I’ve tried various IntelliJ releases and just don’t like it. They’ve even sent me free licenses to review the product for my blog… but I really don’t like it and didn’t want to write up anything so negative given their generosity of letting me try it out for free.
I used to quite like Eclipse, so I used Counter ClockWise for a while for my Clojure dev but that was just too slow on the Linux Netbook I was using for a year or so when traveling (and it was sluggish on Windows too).