Sha256: 15d6f9f8ae97dc5336bf3a7d37d80510b98247f9f4d6b2db503ae6ef87da4163
Contents?: true
Size: 500 Bytes
Versions: 5
Compression:
Stored size: 500 Bytes
Contents
require File.join(File.dirname(__FILE__), '..', '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
5 entries across 5 versions & 2 rubygems