Sha256: 97998d5b63080b32e197a16c9c1637e8ddb0636b9919c37393dbbe5294488063
Contents?: true
Size: 440 Bytes
Versions: 1
Compression:
Stored size: 440 Bytes
Contents
require './test/helper' require 'ludy/z_combinator' class TestZCombinator < Test::Unit::TestCase include Ludy def test_z_combinator fact_ = lambda{|this| lambda{|n| n==1 ? 1 : n*this[n-1]} } fact = Z[fact_] assert_equal(3628800, fact[10]) fib_ = lambda{|this| lambda{|n| n<=1 ? 1 : this[n-2]+this[n-1]} } fib = Z[fib_] assert_equal([1,1,2,3,5,8,13,21,34,55], (0...10).map(&fib)) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ludy-0.1.15 | test/ludy/test_z_combinator.rb |