mirror of
https://github.com/PeterCamilleri/fOOrth
synced 2024-11-16 07:47:56 +01:00
Added >> to the Array class.
This commit is contained in:
parent
5108b2cdcc
commit
a698d6c145
2 changed files with 6 additions and 0 deletions
|
@ -283,6 +283,8 @@ class ArrayLibraryTester < Minitest::Test
|
|||
foorth_equal('[ 9 3 5 ] [ 4 1 ] << ', [[9,3,5,[4,1]]])
|
||||
foorth_equal('[ 9 3 5 ] [ 4 1 ] << ', [[9,3,5,[4,1]]])
|
||||
|
||||
foorth_equal('[ 9 3 5 ] 0 >> ', [[0,9,3,5]])
|
||||
|
||||
foorth_equal('[ 9 3 5 ] 0 + ', [[9,3,5,0]])
|
||||
foorth_equal('[ 9 3 5 ] [ 0 ] + ', [[9,3,5,0]])
|
||||
foorth_equal('[ 9 3 5 ] { } + ', [[9,3,5,{}]])
|
||||
|
|
|
@ -119,6 +119,10 @@ module XfOOrth
|
|||
Array.create_shared_method('<<', NosSpec, [],
|
||||
&lambda {|vm| vm.poke(self << vm.peek); })
|
||||
|
||||
# [ [ 3 1 2 ] n ] >> [ [ n 3 1 2 ] ]
|
||||
Array.create_shared_method('>>', NosSpec, [],
|
||||
&lambda {|vm| vm.poke(self.insert(0, vm.peek)); })
|
||||
|
||||
# [[3 1 2] n] + [[3 1 2 n]]
|
||||
Array.create_shared_method('+', NosSpec, [],
|
||||
&lambda {|vm| vm.poke(self + vm.peek.in_array); })
|
||||
|
|
Loading…
Reference in a new issue