June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,24 @@
|
|||
USING: formatting io kernel math math.functions math.parser
|
||||
prettyprint sequences splitting ;
|
||||
IN: rosetta-code.trabb-pardo-knuth
|
||||
|
||||
CONSTANT: threshold 400
|
||||
CONSTANT: prompt "Please enter 11 numbers: "
|
||||
|
||||
: fn ( x -- y ) [ abs 0.5 ^ ] [ 3 ^ 5 * ] bi + ;
|
||||
|
||||
: overflow? ( x -- ? ) threshold > ;
|
||||
|
||||
: get-input ( -- seq )
|
||||
prompt write flush readln " " split dup length 11 =
|
||||
[ drop get-input ] unless ;
|
||||
|
||||
: ?result ( ..a quot: ( ..a -- ..b ) -- ..b )
|
||||
[ "f(%u) = " sprintf ] swap bi dup overflow?
|
||||
[ drop "overflow" ] [ "%.3f" sprintf ] if append ; inline
|
||||
|
||||
: main ( -- )
|
||||
get-input reverse
|
||||
[ string>number [ fn ] ?result print ] each ;
|
||||
|
||||
MAIN: main
|
||||
Loading…
Add table
Add a link
Reference in a new issue