Original solution
(λ (n) (((((λ(f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (q) (λ(n) (λ(c) (λ(r) (cond [(< c 0)r][(= 1 1) (((q n) (- c 1))(cons(cond [(= 0((((λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (r) (λ(a)(λ (b) (cond [(< a b)a][(= 1 1)((r(- a b)) b)])))))c)2))((((((λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (r)(λ (s) (λ(e) (λ(t) (λ(a) (cond [(>= (* t s) (* t e)) a][(= 1 1)((((r s) (- e t)) t) (cons(- e t)a))])))))))(+ 1(* c n))) (+ 1(* c n)n)) 1) '())][(= 1 1) ((((((λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (r) (λ(s) (λ(e) (λ(t) (λ(a) (cond [(>= (* t s) (* t e)) a][(= 1 1)((((r s) (- e t)) t) (cons(- e t)a))]))))))) (+ (* c n)n))(* c n))-1) '())]) r))]))))))n) (- n 1)) '()) )
Try it online! (Note that the TIO code is slightly different because I've wrapped the solution in (... 4) to call it.)
I picked ISL with Lambda over standard Racket on this and my other answer because I wanted to have short regexes and minimize loopholes. To do it, I started with this:
(define Y (λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y) ((x x) y))))))) (define % (Y (λ (r) (λ (a) (λ (b) (cond [(< a b) a] [(= 1 1) ((r (- a b)) b)])))))) (define range1 (Y (λ (r) (λ (s) (λ (e) (λ (t) (λ (a) (cond [(>= (* t s) (* t e)) a] [(= 1 1) ((((r s) (- e t)) t) (cons (- e t) a))])))))))) (define g (Y (λ (q) (λ (n) (λ (c) (λ (r) (cond [(< c 0) r] [(= 1 1) (((q n) (- c 1)) (cons (cond [(= 0 ((% c) 2)) ((((range1 (+ 1 (* c n))) (+ 1 (* c n) n)) 1) '())] [(= 1 1) ((((range1 (+ (* c n) n)) (* c n)) -1) '())]) r))]))))))) (define (f n) (((g n) (- n 1)) '()))
(Look familiar? I translated this into tinylisp for a certain crack.) Y it the applicative-order Y combinator, taken from this blog post. All functions are curried to make using the Y combinator possible. Then I substituted the function bodies in for each reference to a function and turned f into a lambda. After that, all I had to do was play with spaces so that I could use .\W instead of .\W+ in my regex.