Good to see the long term fruits of community outreach, although the
contest sounds like it was more fun than that :-)
On Wed, Apr 13, 2016 at 6:55 PM, Roger Hui
wrote:
> Olin Shivers, one of the co-authors of the paper, was a judge in the ICFP
> '98 programming contest. http://www.jsoftware.co
Thanks Raul, Kip --
(1) Am now comfortable (again) with foreign print precision; just for
the record:
def=. 6
ext=. 13
9!:10 '' NB. check
6
9!:11 (ext) NB. set
9!:10 '' NB. check
13
9!:11 ] def NB. reset
9!:10 ''
6
(2) The tacit version looks pretty straight forward
The following is not simpler but invents a "continued root" in which dyadic
root %: plays the role dyadic % plays in a continued fraction.
Here is the picture of a "continued root":
a1
b0 + %:
b1 + a2
%:
b2 + a3
One thing you could do is get rid of the intermediate names in gr:
gr=: monad define
1-~ (+&%:)/ y$1
)
And you might want to make this tacit, for example:
13 :'1-~ (+&%:)/ y$1'
1 -~ [: +&%:/ 1 $~ ]
Or, depending on your preferences, you might want to use induction
rather than insertion:
Moving from continued fraction to continued square root, I arrived at this:
NB. modelling gr=. rt(1+rt(1+rt(1+rt(1+...
gr=. monad define
ps=. +
rt=. %:
v=. y $ 1
r=. 1-~ (ps&rt)/ v
)
gr 10
1.61798
gr 13
1.61803
Q1:
What would be (more elegant and/or concise) ways to do this,
e
I think you meant (balancing the parentheses),
*: ((+&)/(@({. , {:))) 3 4 5 6
45
which is a clever solution for the particular form u@{. + u@{: . The
question is: Can you extend your refactoring approach to deal with other
more complicated forms (for example, u@:(u@:{. + u@:{:) , etc.