Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Post Lisp Code

Name: Anonymous 2012-07-23 3:49

JUST POST SOME FUCK ING LISP!!!!

(defun generate-expr (&key fn-list term-list max-depth method)
  (if (or (= max-depth 0)
      (and (eq method :grow)
           (< (random 1.0)
          (/ (length term-list) (+ (length term-list) (length fn-list))))))
      (nth (random (length term-list)) term-list)
      (let* ((fn (nth (random (length fn-list)) fn-list))
         (arity (length `(swank-backend:arglist ,fn))))
    (cons fn (loop for i from 0 to arity
         collect (generate-expr :fn-list fn-list :term-list term-list :max-depth (1- max-depth) :method method))))))

Name: Anonymous 2012-07-24 2:35

(define (dubs em)
  (define (check them)
    (= (% them 10)
       (/ (% (- them (% them 10)) 100) 10)))
   (check em))

(define (% a b) (cond ((< (- a b) 0) a)
  (else (% (- a b) b))))

(dubs 122)
;Value: #t
(% 122 11)
;Value: 1


Using %11 doesn't work past numbers with value > 100 whereas this will.

Trips checker written in reference to the dubs checker.

(define (trips em)
  (cond ((dubs em) (dubs (/ (- em (% em 10)) 10)))
        (else #f)))

(trips 323)
;Value: #f
(trips 333)
;Value: #t

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List