[Solved] Write scheme LISP Atomic_Count [closed]

Not too hard, the main point is that you need some kind of buffer (called prev in my case) to wait for a possible multiplication: (define (atomic_count lst) (let loop ((lst lst) (prev 0)) (if (null? lst) prev (let ((elt (car lst))) (cond ((list? elt) (+ prev (loop (cdr lst) (loop elt 0)))) ((number? elt) … Read more

[Solved] how to do multiply-all function in RACKET

For the simplest solution, use apply for this: (define (multiply-all lst) (apply * lst)) If you need to build the procedure from scratch, just remember that the base case (an empty list) should return 1, and the recursive step should multiply the current value using the standard solution template, like this: (define (multiply-all lst) (if … Read more

[Solved] how to spell a number in racket? (spellNum) [closed]

EDITED: A complete solution has been posted, so I guess it’s ok for me to show you how to write an idiomatic procedure. Notice that number->list uses a technique called tail recursion for efficiently expressing a loop. Although (coming from a Python background) it might be tempting to use an explicit looping construct (as shown … Read more