Sha256: bec79087304b092c06b5ce089f1a0150ff877bab40a75c94a38c27303ad1eda6
Contents?: true
Size: 695 Bytes
Versions: 9
Compression:
Stored size: 695 Bytes
Contents
require 'spec_helper' describe 'Tail recursion' do it 'does not consume stack space for self tail calls' do kl_eval <<-EOS (defun count-down (X) (if (= X 0) success (count-down (- X 1)))) EOS kl_eval('(count-down 10000)').should == :success end it 'does not consume stack space for mutually recursive tail calls' do kl_eval <<-EOS (defun even? (X) (if (= X 1) false (odd? (- X 1)))) EOS kl_eval <<-EOS (defun odd? (X) (if (= X 1) true (even? (- X 1)))) EOS kl_eval('(even? 100000)').should == true kl_eval('(odd? 100000)').should == false end end
Version data entries
9 entries across 9 versions & 1 rubygems