Parentheses inside an anonymous function with a vector as a parameter

I am still learning clojure and I have doubts.

when I write an anonymous function, I do it

fn [parameter] 
 (do something)

ok .. function body is enclosed in parentheses

now i'm reading a fibonacci solution like this

(iterate (fn [[a b]] [b (+ a b)]) [0 1]))

My doubt is why I don't like it

(iterate (fn [[a b]]  (    [b (+ a b)]   ))   [0 1]))

I turn on the function ()

(iterate (fn [[a b]]   "("    [b (+ a b)]   ")"  )   [0 1]))

it receives a vector and then returns a function of the body than another vector ...

This is different when I call a function with a vector parameter or I make a big mistake.

+3
source share
2 answers

, , . "" , , , .

, , "" [foo,bar,baz]. , {:a foo, :b bar, :c baz}. , .

, "" , , (fn [] ...), #(...) (defn [] ...).

: [, ], { } (vector) (hash-map) , [1,2,3] - , (vector 1 2 3), {:a foo, :b bar} (hash-map :a foo :b bar). , "", , Clojure, .

+8

, , Semperos, [1 2 3] / ( 1 2 3), ! {: a 1: b 2}, (hash-map: a 1: b 2).

, , clojure , - [..] (vector...) : -).

+1

All Articles