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

Damn it /prog/

Name: Anonymous 2009-07-27 14:50

I wrote some actual programmes when you were down. Please don't leave me again.

Name: Anonymous 2009-07-27 23:05

>>23
It's shit but it works. There's a tweakable magic number in the normalized-sine function. If you make it half of the length of the string then you'll always get one complete wave. I'm sure it could be done entirely with string functions but I made it into a list because I suck.

(define omg-sine
  (λ(string)
    (let* ((duplicate (λ(string n) (let L ((accum "")
                                           (n n))
                                     (if (zero? n)
                                         accum
                                         (L (string-append accum string) (- n 1))))))
           (next-tag (λ(last-height current-height)
                       (if (= last-height current-height)
                           empty
                           (string->list (duplicate (if (positive? (+ last-height current-height))
                                                        (if (> last-height current-height) "[/sup]" "[sup]")
                                                        (if (< last-height current-height) "[/sub]" "[sub]"))
                                                    (abs (- last-height current-height)))))))
           (normalized-sine ((λ(n) (λ(x) (inexact->exact (round (* n (sin (/ (* x pi) n))))))) 10)))
      (let L ((accum empty)
              (list (string->list string))
              (last-height 0)
              (position 0))
        (if (empty? list)
            (list->string (append accum (next-tag last-height 0)))
            (let ((current-height (normalized-sine position)))
              (L (append accum (next-tag last-height current-height) (cons (car list) empty))
                 (cdr list)
                 current-height
                 (+ position 1))))))))

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