Fork me on GitHub
#beginners
<
2019-05-19
>
Chase13:05:53

Just watched this fun little Clojure/north talk on making quick scripts using cljs and Lumo. https://www.youtube.com/watch?v=dzXZVnfp2TA How exactly would I start trying this out? I see the small little bash script command at the top, right. !#/usr/bin/env lumo. Do I just put this in a standalone cljs file or is it still a whole project thing like using lein new app ... still. How would I actually run it? $: ./my_script.cljs?

Chase14:05:32

Think I got it! Use chmod to give myself permission first and then run it like a normal script. very cool!

🆒 4
Kari Marttila19:05:23

For those of you who are also reading "Programming Clojure" 3rd edition I strongly recommend to download the examples code and run the examples code in repl. E.g. My first impression when reading example code in pages 46-47:

(defn indexed [coll] (map-indexed vector coll))
(defn index-filter [pred coll]
  (when pred 
    (for [[idx elt] (indexed coll) :when (pred elt)] idx)))
was: 😧 (emoji: anguished = experiencing or expressing severe mental or physical pain or suffering) But once I diced and sliced those expressions bit by bit in repl (actually in a scratch file and sending the expressions to repl), and learning what map-indexed does and that you can use sets as functions to test if parameter is in the set etc. I finally managed to understand the example. And then happened something amazing. Now when I understand what individual expressions do in isolation I can look at the example and somehow "see" how for sequence comprehension travels the (indexed coll) and takes the indexes if the character is in the predicate (set). Amazing.

Kari Marttila19:05:32

But it took time. Maybe some 30 minutes. I think I read the book so that I try all example code in repl unless I'm able to comprehend the example code just by reading the code.

Kari Marttila19:05:50

This is going to take many evenings. Well, I have time. 🙂

Eric Ervin20:05:10

Not sure if I've ever downloaded the code for a book. My theory is that I get it into my brain and muscle memory by typing it out.

seancorfield22:05:14

Yeah, I type the code in directly and try it out. I don't download it.

👍 4