Iteration is for pussies, real men ALWAYS tail recurse everything

iteration is for pussies, real men ALWAYS tail recurse everything
(defun bsort (list)
(labels
((swap (list)
(if (> (car list) (cadr list))
(cons (cadr list) (cons (car list) (cddr list)))
list))

(run (list max &key (accum '()) (n 0))
(if (= n max)
(revappend accum list)
(run (cdr (swap list)) max :accum (cons (car (swap list)) accum) :n (1+ n))))

(main (list n)
(if (= n 0)
list
(main (run list (1- (length list))) (1- n)))))
(main list (length list))))

(let ((list (loop for i from 10000 downto 0 collect i)))
(write (bsort list)))

Attached: 7LrSrmZ.jpg (980x1376, 111.05K)

fuck I'm retarded I used iteration in the let...

(((lisp)))

I don't like your common lisp code desu, also common lisp doesn't guarantee TCO

>common lisp doesn't guarantee TCO
yeah, I'm very concerned about that with my high quality bubblesort user

>real men ALWAYS tail recurse everything
>(let ((list (loop for i from 10000 downto 0 collect i)))
guess you're a pussy after all, OP

Based

tail recurse is for furries

kek
someone need to post some now

then what's the point of tail recursion?

Better stack depth since the call is the last statement, the stack frame doesn't need to be saved.

Recursion is cool, but really only useful for certain tasks. Iteration can translate better to parallel computing like GPUs.

I'm very lazy myself, so lazy evaluation is naturally the most comfortable way of doing things for me.

tell us what real men do when you build a house and have a healthy white family of 5 you colossal faggot

kek

recursion means cleaner and shorter code made quicker at the cost of wasting stack space and (usually) running slower.
You should always use recursion when applicable, unless performance is of primary concern.

this recursive program generates a iterative process, then what's the point??

wrong post :)
tail recursion is a function call that can be optimized out by an optimizing compiler, thus resulting in no performance hit. If it is your only recursive call in your function, then it results in just as fast as iterative code.

pure lambda calculus

Attached: 1657907840808.jpg (240x180, 13.46K)

tail reccursion is literally a for loop with semantics inversed
forloop: continue untill break
tail reccursion: break unless reccursion

>(let ((list (loop for i from 10000 downto 0 collect i)))
lmao this is why LISP failed.

>iteration is for pussies
>(loop for i from 10000 downto 0 collect i)