rss

Just some parentheses madness

Category : English, Programming

(define tri-bulle (lambda (t) (tb '() t #f)))
(define tb
   (lambda (left right perm)
      (if (null? (cdr right))
	  (if perm
	      (tb '() (append left right) #f)
	      (append left right))
	  (let ((first (car right))
		(second (cadr right))
		(tail (cddr right)))
	     (if (<= first second)
		 (tb (append left (list first)) (cons second tail) perm)
		 (tb (append left (list second)) (cons first tail) #t))))))

Just a recursive (pseudo-recursive?) implementation of a bubble sort in Scheme. I was supposed to do that thing in C but I found it more challenging this way. A good occasion to re-discover standard operations on list and how to use bee (Bigloo’s IDE) with emacs.

Post a comment