This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-12
Channels
- # aleph (61)
- # announcements (2)
- # babashka (65)
- # beginners (64)
- # calva (2)
- # clerk (1)
- # cljsrn (1)
- # clojure (60)
- # clojure-austin (7)
- # clojure-europe (13)
- # clojure-italy (2)
- # clojure-losangeles (4)
- # clojure-nl (2)
- # clojure-norway (94)
- # clojure-romania (2)
- # clojure-uk (7)
- # clojuredesign-podcast (5)
- # clojurescript (3)
- # core-typed (2)
- # datomic (42)
- # docker (24)
- # emacs (10)
- # exercism (50)
- # graphql (83)
- # honeysql (25)
- # hyperfiddle (12)
- # malli (13)
- # membrane (49)
- # off-topic (50)
- # podcasts-discuss (1)
- # re-frame (3)
- # reagent (12)
- # reitit (5)
- # releases (2)
- # remote-jobs (8)
@slipset then I hope she is doing better then me . I did now some 12 and im very stuck at solving the rest
Im now busy with the space_age challenge But I wonder what is the best way to link planets to a factor. So I can use the factor in a calculation
I think that is the one which makes sense to use a macro, actually
Because the tests expect you to have a function for calculating the time on each planet
(a function for each planet)
yep , I see that when I open the challenge. I see a lot of methods. One for every planet
when in doubt, use maps
I mean... you could write 9 different functions, but using a macro makes it so you only have to write one
Another way I've seen that avoids macros, and also avoids having to write 9 functions, is to use intern
: https://clojuredocs.org/clojure.core/intern
With that, you can pass a namespace, symbol name, and function body and will define the appropriate function
What does this vague error message mean ;
An unexpected error occurred:
sci.impl.fns$fun$arity_0__1162 cannot be cast to java.lang.Number
with this code :
(defn seconds_year_earth
[]
31557600
)
(defn conversion_ratios
"returns the factor for the seconds a year for a planet"
[planet]
{
:mercury 0.2408467
:venus 0.61519726
}
)
(defn on-earth
[seconds]
(/ seconds seconds_year_earth))
(defn on-mercury
[seconds]
(*(on-earth seconds) (conversion_ratios :mercury)))
I’d argue that your conversions-ratio
function (fn) is a bit unnecessary.
In Clojure maps acts as functions of their keys so you can do the following:
(def conversion-ratios {:mercury 0.2408467 :venus 0.61519726})
Then to get the conversion-ratio for :mercury
you simply do:
(conversion-ratios :mercury)
A thing that we both find difficult is the numbers stuff. It’s quite mathy, especially for a 13 year old (who might not be the target audience) but also for a 50something who’s forgotten most of his maths.
I really enjoyed the robot thingy. It sounds really complicated when reading but we managed to make a rather neat solution with reduce
The cool thing with doing it with reduce
was that on first go we got the wrong answer (we did the exercise on paper first), so we switched to reductions
and could see exactly where we’d done the mistake.
oke, I was stuck at the age-planet challenge but with some help of this channels I think I found a way to solve things
One project I've been planning is a gentle maths course using Clojure for young people, or older folks who have either forgotten or never learned it in the first place, like me
I'm not sure if this would be a fit for Exercism though. They tried to do something similar in the Julia track, but it was never finished.
Jeremy, the CEO, said that it wasn't likely to be viable because it strayed too far from the pedagogical style that Exercism uses. As I recall it involved the student building up over several exercises, a mini maths library. But this is something that I'm going to build in any case, because I think it's really important.
Again, perhaps not the target audience, but the language of the exercises seem a bit theoretical for my 13 year old.
Like, on strings,
> A string
in Clojure is a Java string, which is an object that represents immutable text as a sequence of Unicode characters (letters, digits, punctuation, etc.) and is defined as follows:
is the introduction. There were so many questions asked when she read this sentence. Also, IMO, so much information here that she didn’t need in order to do the exercises or to learn about strings.
Please do tell me to shut up if I’m rambling about stuff that is not interesting.
The feedback is much appreciated 🙂 The target audience of Exercism is indeed people who have experience in at least one other language
🙂 My daughter started on the Python track, but I got tired of the whitespace stuff and switched her over to Clojure 🙂
For awhile they were kicking around an idea for a whole new "Learn to Code" platform to address this gap
But, she is really enjoying this, and she’s working on the problems on her own, and I get to help her. So my comments are mostly nitpicks.
She’s also found an online Clojure repl where she tries out her solutions when the tests don’t pass 🙂
I wrote a REPL plugin for the Exercism editor that uses SCI, but unfortunately it was never added to the site
I got a bit annoyed when she was working on the “bird watcher” because I suggested a solution like:
(defn inc-bird [birds]
(conj (vec (butlast birds)) (inc (last birds))))
Which made me have to explain to her how conj
works differently for lists and vectors (which she seemed to grasp)
But then later I realized that the suggested solution would be with update
which I hadn’t even thought about.and I guess reaching for butlast
should have been a sign for me to consider another solution 🙂
It was a challenge to port some of those exercises, because they were written for other languages and it was often awkward to make it work in Clojure without totally reworking them
Ya, I can see that some of this stuff is a bit forced or something in Clojure. Like “tracks on tracks” has a lot of fns which are not really that useful in Clojure.
Like add-language
is a fn I’d probably never write, as that’s basically conj
Exactly, I'm not a fan of that exercise because it's just having you shadow core functions. And the final task is best solved with a threading macro but those haven't been taught yet at that point
My plan is to make a different exercise for lists, and rework that one to teach threading macros
Interestingly this is our solution:
(defn learning-list
"Creates an empty list, adds Clojure and Lisp, removes Lisp, adds
Java and JavaScript, then finally returns a count of the total number
of languages."
[]
(-> (new-list)
(add-language "clojure")
(add-language "lisp")
(remove-language)
(add-language "Java")
(add-language "JavaScript")
(count-languages)))
I had to introduce the threading macro here, because otherwise she would have rage-quit Clojure, and we couldn’t have that.
The concept of the threading macro was easy for her to grasp. I didn’t use the m word, I just told her what it did.
She asked for the as->
thread, but I told here we don’t want to have a thing like that, ->
and ->>
suffices 🙂I'm glad you managed to get through it 🙂 I think I might do some work on this today
Anyways, thanks for the work you’re putting in. As I said, Una is really enjoying this, and it’s really fun to work with her on them.
That's great to hear 🙂