When should you use a list and when should you use a vector?
A good rule of thumb is that if you need to easily add items to the beginning of a sequence or if you’re writing a macro, you should use a list. Otherwise,you should use a vector.
➊ (defntoo-enthusiastic➋ "Return a cheer that might be a bit too enthusiastic"➌ [name]➍ (str"OH. MY. GOD! " name " YOU ARE MOST DEFINITELY LIKE THE BEST ""MAN SLASH WOMAN EVER I LOVE YOU AND WE SHOULD RUN AWAY SOMEWHERE"))
;;use this functions (too-enthusiastic"Zelda") ; => "OH. MY. GOD! Zelda YOU ARE MOST DEFINITELY LIKE THE BEST MAN SLASH WOMAN EVER I LOVE YOU AND WE SHOULD RUN AWAY SOMEWHERE"
1 2 3 4
(defnmulti-arity;; 3-arity arguments and body ([first-arg second-arg third-arg] (do-things first-arg second-arg third-arg)) ;; 2-arity arguments and body ([first-arg second-arg] (do-things first-arg second-arg)) ;; 1-arity arguments and body ([first-arg] (do-things first-arg)))
1 2 3
;; Return the first element of a collection (defnmy-first [[first-thing]] ; Notice that first-thing is within a vector first-thing) (my-first ["oven""bike""war-axe"]); => "oven"