Sha256: 4888815bc038063278a79fe3018ffcc75c08675cc92290c3f093d9b19adea728
Contents?: true
Size: 491 Bytes
Versions: 9
Compression:
Stored size: 491 Bytes
Contents
require File.join(File.dirname(__FILE__), '..', 'lib', 'ludy/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
9 entries across 9 versions & 1 rubygems