Skip to content

Instantly share code, notes, and snippets.

@treed
Created July 13, 2009 21:40
Show Gist options
  • Save treed/146470 to your computer and use it in GitHub Desktop.
Save treed/146470 to your computer and use it in GitHub Desktop.
a = [1,2,3]
puts a
a = a * 3
puts a
a = [1,2,3]
a = a * ":"
puts a
.sub 'infix:*' :multi('CardinalArray','CardinalInteger')
.param pmc this
.param pmc count
.local pmc array
.local int i
say "Entered *i"
i = count
if i > 0 goto sane
$P0 = undef()
.return ($P0)
sane:
say "Verified sanity"
array = new 'CardinalArray'
loop:
say "Beginning loop."
array.'append'(this)
say "Appended array."
dec i
say "dec i"
say i
if i > 0 goto loop
say "about to return"
.return (array)
.end
[14:35] [inara:/Users/treed/code/cardinal]% ./cardinal arraytest.rb
[1, 2, 3]
Entered *i
Verified sanity
Beginning loop.
Appended array.
dec i
2
Beginning loop.
Appended array.
dec i
1
Beginning loop.
zsh: bus error ./cardinal arraytest.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment