How do I convert a number to a list of digits?
I am currently doing:
;; (num->list 12345) -> \'(1 2 3 4 5) (define (num->list n) (local
Here's how I'd do it in Racket:
(require srfi/1 srfi/26) (define (digits->list num (base 10)) (unfold-right zero? (cut remainder <> base) (cut quotient <> base) num))
This is the sort of problem unfold was designed for. :-D
unfold