[q-lang-users] [Fwd: Why cant I differentiate]
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2007-06-09 07:39:17
|
Hi all, this is a post by Koray Erkan which, for some reason we both don't understand, bounced back from the sf.net mailing list server even though he's subscribed to the list, so I'm posting it on his behalf. Until Koray gets his mailing problems sorted out, please be so kind to cc your replies to ke-1256 (at) isnet.net.tr. Thanks. Albert -------- Original Message -------- Subject: Why cant I differentiate Date: Sun, 3 Jun 2007 11:21:39 +0300 From: Koray Erkan <ke...@is...> To: <q-l...@li...> <div class="moz-text-flowed" style="font-family: -moz-fixed">Hi -- I'm very new to Q. I've copied the following bits of code from a white paper ("Why Functional Programming Matters") - making a few very minor changes to meet Q's syntax requirements as needed. It doesn't run, and my hunch is there's something wrong with the "repeat" bit of it. I know it returns and infinite list, but I've tried using an accessor (i.e. "(list)! <index-id>") to get a single returned value which in turn didn't work. I'm probably trying to fit square pegs into round holes somewhere, but as I don't have the time to check every option, I thought of consulting the mailing list. Your help will be appreciated. -- easydiff F X H = (F (X+H) - F X) / H; differentiate H0 F X = map (easydiff F X) (repeat halve H0); halve X = X/2; elimerror N (cons A (cons B Rest)) = cons ((B*(2^N)-A)/(2^N-1)) (elimerror N (cons B Rest)); order (cons A (cons B (cons C Rest))) = round (log2 ((A-C)/(B-C) - 1)); improve S = elimerror (order S) S; super S = map second (repeat improve S); second (cons A (cons B Rest)) = B; -- BTW Is there a way to "step" through the code ? Dijkstra would probably write another paper how stepping through code "maimes/cripples" the mind forever (good old Dijkstra, much as respect him, he can't seem to get through a paper without somebody being crippled or a methodology that would require a gazillion-dollar industry change isn't suggested ;-D), but as I don't have a 170 IQ (a fact which Dijkstra and his ilk frequently forget in dealing with these matters), I am not able to shuffle and update 37 variables simultaneously in my head or eat tensor calculus formulae for breakfast. To make a loose analogy with a "disabled" person, a wheel-chair may appear "crippling" to someone perfectly able to walk (say Dijkstra), but to someone who has lost his walking ability, it is *liberating*. Same thing with IQ and computer-interaction: No matter what our genius (elite) computer scientists say, a debugger that can step through code is liberating - at least to those of us crippled with less IQ. Cheers -- Koray </div> -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |