[Jprogramming] forward differences
R.E. Boss
r.e.boss at planet.nl
Thu Dec 13 06:22:45 HKT 2007
diffx=: 4 :'(}. - }:)^:x y'
5 diffx (i.10)^5
120 120 120 120 120
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van: programming-bounces at jsoftware.com [mailto:programming-
> bounces at jsoftware.com] Namens Tracy Harms
> Verzonden: woensdag 12 december 2007 23:13
> Aan: programming at jsoftware.com
> Onderwerp: [Jprogramming] forward differences
>
> Awhile back Rob Hodgkinson brought my attention to the
> forward difference function.
>
> ] a=:(i.10)^3
> 0 1 8 27 64 125 216 343 512 729
> diff=: }. - }:
> diff a
> 1 7 19 37 61 91 127 169 217
> diff^:3 a
> 6 6 6 6 6 6 6
>
> I want to write a verb that uses the left parameter to
> identify the order of forward difference, and the
> right for the data.
>
> The problem I encounter seems to turn on my need to
> process a monadic verb within a dyadic context. Here
> are some failed incremental efforts:
>
> diff1=: }. - }:^:1
> diff1 a
> 1 7 19 37 61 91 127 169 217
> NB. Success to that small degree. But:
> diffx=: }. - }:^:[
> 1 diffx a
> |domain error: diffx
> | 1 diffx a
> NB. Explicit definition also fails:
> diffxe=: 3 : '}. - }:^:x y'
> 1 diffxe a
> |domain error: diffxe
> | 1 diffxe a
>
> How do I keep the left parameter from forcing a dyadic
> interpretation of (}. - }:)? Or, is that not the
> problem?
>
>
> --
> Tracy B. Harms
>
> The advantages of executability and universality
> found in programming languages can be effectively
> combined, in a single coherent language, with the
> advantages offered by mathematical notation.
> Kenneth E. Iverson
>
>
>
> __________________________________________________________________________
> __________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile. Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list