Sha256: 5d01ebfaf3e6ef749946c5559b6891ec9c05fac731384eb5dda45b70ed4ab911
Contents?: true
Size: 517 Bytes
Versions: 9
Compression:
Stored size: 517 Bytes
Contents
require File.join(File.dirname(__FILE__), '..', 'lib', 'ludy/test/helper') require 'ludy/y_combinator' include Ludy # why should this be here? class TestYCombinator < Test::Unit::TestCase def test_y_combinator fact_ = lambda{|this| lambda{|n| n==1 ? 1 : n*this[n-1]} } fact = Y[fact_] assert_equal(3628800, fact[10]) fib_ = lambda{|this| lambda{|n| n<=1 ? 1 : this[n-2]+this[n-1]} } fib = Y[fib_] assert_equal([1,1,2,3,5,8,13,21,34,55], (0...10).map(&fib)) end end
Version data entries
9 entries across 9 versions & 1 rubygems