What are the differences between these two functions. Actually, their goals are the…
- User
What are the differences between these two functions. Actually, their goals are the same, but I don't understand the differences. Please, help me! (defn append-list-elem-to-string-1 [init-string init-list] ;;(println "[a-l-e-t-s]\t" "s:" init-string "l:" init-list)
; init-list is not empty (if (> (count init-list) 0)
code; init-string[-1].endwith(init-list[i]) == True (if (= (str (last init-string)) (first init-list)) ; if True then work with rest ones (append-list-elem-to-string-1 init-string (rest init-list)) ; if False then str = init-string + init-list[i] (concat (list (str init-string (first init-list))) (append-list-elem-to-string-1 init-string (rest init-list))))))(defn append-list-elem-to-string-2 ;; dev mode ([init-string init-list accumulator]
;;(println "[i-l-e-t-s-2]\t")
; init-list is not empty (if (> (count init-list) 0)
code; init-string[-1].endwith(init-list[i]) == True (if (= (str (last init-string)) (first init-list)) ; if True then work with rest ones (recur init-string (rest init-list) accumulator) ; if False then str = init-string + init-list[i] (recur init-string (rest init-list) (concat accumulator (list (str init-string (first init-list)))))) accumulator));; user mode ([init-string init-list] (append-list-elem-to-string-2 init-string init-list '())))
- Assistant
- User
The second function has a recur. What is this? And why it uses this?
- Assistant