1. rgrau
  2. language-learning-apps

Source

language-learning-apps / factor / hipotenuse.factor

1
2
3
4
5
6
7
8
9
#!/home/rgrau/programmingStuff/factor/factor -script
USING: kernel command-line formatting prettyprint sequences formatting math.parser math.functions regexp io math ;
IN: hipotenuse

: read-num ( -- x ) readln string>number ;
: hipotenuse ( x y -- h ) sq swap sq + sqrt ;
: print-it ( x -- ) "%.3f" sprintf R/ .?0*$/ "" re-replace . ;

read-num read-num hipotenuse print-it