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

Opinions on a quick C tutorial

Name: Anonymous 2013-03-17 22:03

http://wololo.net/talk/viewtopic.php?f=37&t=6236

Shoot it up and I'll let the author know.

Name: Anonymous 2013-03-18 1:53

Damn, I want to make vidya, but tinyscheme can't...

; tree.scm
(define (spawn h)
  (if (= 0 h)
      '()
      (cons h
            (cons (spawn (- h 1))
                  (spawn (- h 1))))))

(define (sum x)
  (if (null? x)
      0
      (+ (car x)
         (sum (car (cdr x)))
         (sum (cdr (cdr x))))))

(display (sum (spawn 23)))


$ tinyscheme tree.scm
No memory!


But lua works fine!

-- tree.lua
local function spawn(h)
    if h > 0 then
        return { n=h, a=spawn(h-1), b=spawn(h-1) }
    end
    return nil
end

local function sum(node)
    if node then
        return node.n + sum(node.a) + sum(node.b)
    end
    return 0
end

print(sum(spawn(23)))


result             time(s)
luajit-2.0.1        4.159
racket-5.3.3        4.460
lua-5.1.5          10.280
tinyscheme-1.40      :(


squirrel next?

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