[Jprogramming] Reduce with initial value?
Joe Bogner
joebogner at gmail.com
Tue Jun 23 02:20:23 UTC 2015
This came up on irc the other day and here's my contrived problem and
solution: https://gist.github.com/joebo/a3b08b6e8422473803bc
The request was to be take a table of games and return a table of team
scores for all the games. The team scores were dependent upon the
current team score at the time of the team playing the game.
The solution created an initial team score matrix and passed that
along for each iteration which was amended
On Mon, Jun 22, 2015 at 9:53 PM, Marshall Bockrath-Vandegrift
<llasram at gmail.com> wrote:
> Hi all,
>
> I'm still in the process of learning J, and trying to adapt ideas from
> other languages. In many (other?) functional programming languages it is
> possible to reduce over a collection starting with a provided initial value
> which does not belong to the reduced collection. To attempt to put this in
> J terms, such an operation would allow the initial value and result of each
> reduction step to have a different shape than that of the the items of the
> value being reduced. As far as I can tell, the standard `/` adverb provides
> no such facility. Is there a J idiom for this?
>
> Thanks,
>
> -Marshall
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list