Fork me on GitHub
#practicalli
<
2021-07-11
>
practicalli-john14:07:25

I've started working on a lot of updates and additions to the Practicalli content and there is a huge amount to do. I'm updating the links and content around 4Clojure, as its now been replaced by 4ever-clojure - https://4clojure.oxal.org/

practicalli-john14:07:04

I've also added a link to re-find website to https://practical.li/#resources as its a great tool to help you find Clojure functions based on the shape of arguments and return values.

practicalli-john15:07:36

I am starting to re-design the layout of the main Practicalli web page, to make it easier to understand all the books I am working on - https://practical.li/practicalli-landing-page/#books I have updated the alpha stage books, which seems nicer. I also tweaked some of the graphics. I'm tweaking the code to use generator functions to create all the hiccup code, rather than have it all done my hand. I find it easier to write hiccup code first and then write a generator function after. I'll add more details of building these sorts of ClojureScript / Reagent landing pages to the Practicalli Clojure book soon (there are a couple of examples there already)

practicalli-john20:07:56

I have been using the for form to refactor the Practicalli landing page hiccup code, so repetitive code is generated. For example, to generate the list of books, I define the specific book details in a collection of hash-maps and pass that to a function that generates the hiccup for each book in the collection. Then each book is pulled from the collection as a local name, i.e. book

(for [book books]
  ;; hiccup template code
  (get book :url) 
)
To avoid multiple get calls, or threading the hash-map through the key, I wanted to do some destructuring of each hash-map in the for. {keys [title description url image]} will destructure each book in the collection of books The for takes a :let directive, although it seems that does not work with this type of desctructuring However, destructuring in the sequence expressions does work
(for [{keys [title description url image]} books])
I didnt see kind of example on clojuredocs, so I added one here https://clojuredocs.org/clojure.core/for#example-60eb570de4b0b1e3652d7516

practicalli-john21:07:46

I've updated the Practicalli landing page with the new book layout. Hopefully this is clearer as to each books intent. https://practical.li/

3
🎉 7
👍 12