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

Scheme Challenge

Name: Anonymous 2009-06-19 22:40

Write a scheme program that does anything that would be significantly more verbose if coded in another language. 
Size should be measured in characters (wc -m), non-signficant white space should not be counted.

Name: Anonymous 2009-06-19 22:56

>>1
Am I to assume we disallow Common Lisp as the other language?

Name: Anonymous 2009-06-19 23:06

>>1
Are we disallowing APL and Factor as well? Forth?

Name: Anonymous 2009-06-19 23:06

>>2
Yes. If your preference is to use another lisp dialect feel free to use that to.

Name: Anonymous 2009-06-19 23:12

>>4
That was not the question!

Name: Anonymous 2009-06-20 0:39

Haskell:
subsets = filterM (const [True,False])

Scheme:
(define (subsets s)
  (if (null? s)
      (list (list))
      (let ((rest (subsets (cdr s))))
        (append rest (map (lambda (x) (cons (car s) x))
                          rest)))))
(SICP Exercise 2.32)

Name: Anonymous 2009-06-20 2:03

Conway's Game of Life
Next generation in Lisp:
(defun live (cur)
  (let* ((w (array-dimension cur 0))
         (h (array-dimension cur 1))
         (next (make-array (list w h) :initial-element nil)))
    (labels ((neighbors (x y)
               (count-if 'identity
                         (mapcar (lambda (d)
                                   (aref cur
                                         (mod (- x (car d)) w)
                                         (mod (- y (cdr d)) h)))
                                 '((-1 . -1) ( 0 . -1) ( 1 . -1)
                                   (-1 .  0)           ( 1 .  0)
                                   (-1 .  1) ( 0 .  1) ( 1 .  1)))))
             (lives (x y)
               (let ((ns (neighbors x y)))
                 (if (or (= ns 3)
                         (and (aref cur x y) (= ns 2)))
                     t nil))))
      (dotimes (i w)
        (dotimes (j h)
          (setf (aref next i j) (lives i j)))))
    next))

In APL: life←{↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}

Name: Anonymous 2009-06-20 3:01

{↑1 ⍵ 1↑}

Name: Anonymous 2009-06-20 3:07

>>8
Invalid APL code. Valid Perl.

Name: Anonymous 2009-06-20 3:28

>>9
not enough $_

Name: Anonymous 2009-06-20 4:16

Scheme, 24 chars
(display "Hello World!")

HTML, 13 chars
Hello World!

Almost twice as long....

Name: Anonymous 2009-06-20 4:26

>>11
Your HTML doesn't compile.

Name: Anonymous 2009-06-20 4:44

>>12
what about .chm files?

Name: Anonymous 2009-06-20 9:22


//Conway's game of life
void life(int[][] cur){
 int[][] next=new int[w][h];
 for(int i=0;i<w;i++)
 for(int j=0;j<h;h++){
  int n=0;
  for(int a=-1;a<2;a++)
  for(int b=-1;b<2;b++){
   n+=cur[(a+i)%w][(b+j)%h];
  } 
  if(cur[i][j]==1&&n==4||n==3)
  next[i][j]=1;
 }
 life(next);
}

Name: Anonymous 2009-06-20 19:06

Name: Anonymous 2009-06-20 19:40

>>14
this indentation transcends space and time

Name: Anonymous 2009-06-20 20:36

// Conways game of dicks
10 PRINT "DICKS"
20 GOTO 10

Name: Anonymous 2009-06-21 4:58

>>17
roffl

Name: !4SUSsmAnSA 2009-06-21 5:01

test

Name: Anonymous 2009-06-21 6:04

>>17

(define (fix f)
  (f (fix f)))
(fix (lambda (f) (display "DICKS") (f)))

Name: Anonymous 2009-06-21 13:28

>>20
gtfo

Name: Anonymous 2011-01-31 21:10

<-- check em dubz

Name: tray 2012-03-14 23:12


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