[racket] Replacing lambdas with defines

From: Ashok Bakthavathsalam (ashokb at kggroup.com)
Date: Fri Jun 8 10:25:22 EDT 2012

Below, I have enclosed the code from Rosetta for generating Permutations.
Can someone show me how to replace nested lambdas with defines?

(define (insert l n e)

  (if (= 0 n)

      (cons e l)

      (cons (car l)

            (insert (cdr l) (- n 1) e))))

(define (seq start end)

  (if (= start end)

      (list end)

      (cons start (seq (+ start 1) end))))

(define (permute l)

  (if (null? l)


      (apply append (map (lambda (p)

                           (map (lambda (n)

                                  (insert p n (car l)))

                                (seq 0 (length p))))

                         (permute (cdr l))))))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120608/3c90ad85/attachment.html>

Posted on the users mailing list.