O'Reilly logo

Clojure for Finance by Timothy Washington

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Destructuring

Earlier, I gave an explanation of a destructuring code block. Here, we'll elaborate on it a little further. The inner let block is where we assigned values to the input-key, output-key, and etal-keys. We can assign these symbols for later use as keys in maps. The input-key, which is assigned in the let block, is later used to pull out the last price from our input list. The output-key is the last average that we calculated in our function. The etal-keys are vectors of price and time, which we used to join those keys with previous values, thereby adding the average key (or output key) and value to each one:

(let [ ... {input-key :input output-key :output etal-keys :etal :or {input-key :last-trade-price output-key :last-trade-price-average ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required