rubyx/lib/soml/parfait/integer.soml
2015-11-11 20:45:40 +02:00

47 lines
742 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 / 10
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 div( Integer by)
int ret = self / by
return ret
end
int mod(Integer by)
int base = self / by
base = base * by
return self - base
end
end