52 lines
1.4 KiB
Text
52 lines
1.4 KiB
Text
[ $ 'bigrat.qky' loadfile ] now!
|
|
|
|
[ [] swap times
|
|
[ 20001 random 10000 -
|
|
n->v 100 n->v v/
|
|
join nested join ] ] is makevector ( --> [ )
|
|
|
|
[ witheach
|
|
[ unpack
|
|
2 point$ echo$
|
|
i 0 > if
|
|
[ say ", " ] ] ] is echodecs ( [ --> )
|
|
|
|
[ dup size n->v rot
|
|
0 n->v rot
|
|
witheach
|
|
[ unpack v+ ]
|
|
2swap v/ ] is arithmean ( [ --> n/d )
|
|
|
|
[ 5 makevector
|
|
|
|
say "Internal representation of a randomly generated vector" cr
|
|
say "of five rational numbers. They are distributed between" cr
|
|
say "-100.00 and +100.00 and are multiples of 0.01."
|
|
cr cr dup echo cr cr
|
|
say "Shown as decimal fractions."
|
|
cr cr dup echodecs cr cr
|
|
|
|
arithmean
|
|
|
|
say "Arithmetic mean of vector as a decimal fraction to" cr
|
|
say "5 places after the point, as a rounded proper" cr
|
|
say "fraction with the denominator not exceeding 10, and" cr
|
|
say "finally as a vulgar fraction without rounding." cr cr
|
|
2dup 5 point$ echo$
|
|
say ", "
|
|
2dup proper 10 round improper
|
|
proper$ echo$
|
|
say ", "
|
|
vulgar$ echo$ cr cr
|
|
|
|
say "The same, but with a vector of 9973 rational numbers," cr
|
|
say "20 decimal places and a denominator not exceeding 100." cr cr
|
|
|
|
9973 makevector arithmean
|
|
|
|
2dup 20 point$ echo$
|
|
say ", "
|
|
2dup proper 100 round improper
|
|
proper$ echo$
|
|
say ", "
|
|
vulgar$ echo$ cr ] is demonstrate ( --> )
|