rubyx/lib/soml/parfait/integer.soml
Torsten Ruger 5c862111b9 remove div and add div10
general division is for another day, the 10 version is manageable
also same code produces mod10
wip
2015-11-12 20:03:57 +02:00

40 lines
618 B
Plaintext

class Integer < Value
int as_char()
if_plus( self - 9)
return 32
else
return 48 + self
end
end
Word as_string(Word str)
if_minus( self - 10 )
int num = as_char()
str = str.push_char( num )
else
int rest = self.div10()
str = rest.as_string( str )
rest = rest * 10
rest = self - rest
str = rest.as_string(str)
end
return str
end
Word to_s()
Word start = " "
return as_string( start )
end
int puti()
Word str = self.to_s()
str.putstring()
return self
end
int mod4()
return self & 3
end
end