Thank you. I knew of the optimization of this kind.
It is difficult for a Haskeller to believe in the necessity of such
loops. When I try this, it takes much more time of me to develop a code
of this kind.
Honestly, when I first read your h function, I had hard times to
decipher it. Fortunately, I learnt about this pattern during a Haskell
course last semester.
Anyway, for me the loop variant is still easier to read. Nevertheless
there are certainly some advantages in a purely functional language.
I've seen some program transformation code that automatically turns a
naively programmed O(n^2) code into O(n) code.
Ralf
PS:
BTW, you can also do it this way...
split3(l: L): Product(L, L) ==
empty? l => [empty$L, empty$L]
c: L := l
r := [(c:=rest c; l:= rest l; x)
for x in l while not empty? c and not empty?(c:=rest c)]
[r, l]
But, of course, one shouldn't promote such kind of programming.
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.