Scheme number to list
问题 I need a subroutine for my program written in scheme that takes an integer, say 34109, and puts it into a list with elements 3, 4, 1, 0, 9. The integer can be any length. Does anyone have a trick for this? I've thought about using modulo for every place, but I don't think it should be that complicated. 回答1: The simplest way I can think of, is by using arithmetic operations and a named let for implementing a tail-recursion: (define (number->list num) (let loop ((num num) (acc '())) (if (< num