rubyx/lib/soml/parfait/integer.soml

27 lines
449 B
Plaintext
Raw Normal View History

2015-11-08 13:30:42 +01:00
class Integer < Value
2015-11-08 16:11:03 +01:00
int digit()
if_plus( self - 10)
return 32
else
Word numbers = "0123456789"
return numbers.at(self)
2015-11-08 13:30:42 +01:00
end
end
2015-11-08 16:11:03 +01:00
Word as_string(Word str)
2015-11-08 22:58:54 +01:00
if_minus( self - 10 )
2015-11-08 16:11:03 +01:00
int num = digit()
str = str.add_digit( num )
2015-11-08 22:58:54 +01:00
else
int rest = self / 10
str = rest.as_string( str )
2015-11-08 13:30:42 +01:00
end
return str
end
2015-11-08 16:11:03 +01:00
Word to_s()
2015-11-08 13:30:42 +01:00
Word start = " "
2015-11-08 16:11:03 +01:00
return as_string( start )
2015-11-08 13:30:42 +01:00
end
end