Jose, I put this together before I read your message, but I'll get back to it.
Dave's "h" is better than "shuf". In a month I'd rather have "i" than "h". To
me 13 : is a way to communicate with other people. Studying the code "i"'s
displays will help you write better code.
F=:52$'23456789TJQKA'
S=:13#u: 9827 9830 9829 9824
deck=:S,.F
shuf=: 13 :'<"2|."2 y {~ /:~"1 (|.x)$?~*/|.x'
h =: [: <"2 ({~ [: \:"1~ |. $ [: ?.~ */)~
i=: 13 :'<"2 x({~ ([: \:"1~ |. $ [: ?.~ */))~y'
j treats "h" and "I" as if they are the same.
shuf
[: <"2 [: |."2 ] {~ [: /:~"1 ([: |. [) $ [: ?~ [: */ [: |. [
h
[: <"2 ({~ ([: \:"1~ |. $ [: ?.~ */))~
i
[: <"2 ({~ ([: \:"1~ |. $ [: ?.~ */))~
t
And all behave the same, but do not match -: because each deal is diffent.
(13 4 shuf deck);' ';(13 4 h deck);' ';<13 4 i deck
┌─────────────┬───┬─────────────┬───┬─────────────┐
│┌──┬──┬──┬──┐│ │┌──┬──┬──┬──┐│ │┌──┬──┬──┬──┐│
││♠A│♠9│♠K│♠J││ ││♠K│♠A│♠J│♥Q││ ││♠K│♠A│♠J│♥Q││
││♠8│♠3│♠Q│♠5││ ││♠4│♠Q│♠T│♥8││ ││♠4│♠Q│♠T│♥8││
││♠6│♠2│♠T│♥A││ ││♥A│♠8│♠9│♥6││ ││♥A│♠8│♠9│♥6││
││♥5│♥K│♠7│♥Q││ ││♥T│♠6│♠7│♥4││ ││♥T│♠6│♠7│♥4││
││♦A│♥J│♠4│♥8││ ││♥2│♠5│♠3│♥3││ ││♥2│♠5│♠3│♥3││
││♦K│♥9│♥T│♥3││ ││♦T│♥K│♠2│♦A││ ││♦T│♥K│♠2│♦A││
││♦J│♥6│♥7│♥2││ ││♦5│♥J│♥9│♦K││ ││♦5│♥J│♥9│♦K││
││♦8│♦Q│♥4│♦5││ ││♦4│♥7│♥5│♦Q││ ││♦4│♥7│♥5│♦Q││
││♦3│♦T│♦7│♦4││ ││♦2│♦J│♦8│♦7││ ││♦2│♦J│♦8│♦7││
││♣A│♦9│♦6│♦2││ ││♣Q│♦9│♦6│♣9││ ││♣Q│♦9│♦6│♣9││
││♣T│♣K│♣Q│♣9││ ││♣T│♣A│♦3│♣8││ ││♣T│♣A│♦3│♣8││
││♣6│♣3│♣J│♣8││ ││♣3│♣K│♣J│♣7││ ││♣3│♣K│♣J│♣7││
││♣5│♣2│♣4│♣7││ ││♣2│♣6│♣5│♣4││ ││♣2│♣6│♣5│♣4││
│└──┴──┴──┴──┘│ │└──┴──┴──┴──┘│ │└──┴──┴──┴──┘│
└─────────────┴───┴─────────────┴───┴─────────────┘
Linda
-----Original Message-----
From: Programming <[email protected]> On Behalf Of Nick S
Sent: Tuesday, October 16, 2018 8:02 PM
To: Jsoftware Programming forum <[email protected]>
Subject: Re: [Jprogramming] Using rank to avoid looping - reference?
Haha. I think / was reduce in APL.
On Wed, Sep 5, 2018, 14:52 'Pascal Jasmin' via Programming <
[email protected]> wrote:
> the wikipage mislabels the / operator as map as well (it is in fact a
> reduce operator)
>
> The functional map function replaces a "for each" loop. Rank is very
> closely tied to this, with the addition of specifying the
> size/slice/scope of the "each element" group
>
>
> On Wednesday, September 5, 2018, 1:56:33 p.m. EDT, Cliff Reiter <
> [email protected]> wrote:
>
>
>
>
>
> From Mathematica help:
>
> Map (Built-in Symbol)
> Map[f, expr] or f /@ expr applies f to each element on the first level
> in expr. Map[f, expr, levelspec] applies f to parts of expr specified
> by levelspec. Map[f] represents\[Ellipsis]
>
>
> On 9/5/2018 10:58 AM, devonmcc wrote:
> > I am trying to bring the Wikipedia page on "rank (J programming
> language)" into compliance with the guidelines by inserting more
> inline references but am stumped by that page's initial assertion that
> rank is a generalization of looping, as well as the subsequent claims
> about rank generalizing "map" and "maplist".
> > Searches for a word like "rank" bring up many irrelevant hits even
> > when
> included with programming-specific terms. Also, the best reference I
> have found so far -
> https://eur04.safelinks.protection.outlook.com/?url=www.ccs.neu.edu%2F
> home%2Fjrslepak%2Ftyped-j.pdf&data=02%7C01%7C%7C91964909f04b4d32b1
> cf08d633c3cb94%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C6367533133
> 59613565&sdata=VE8hYuUVPXG2fI2nspCteTuOr8hI2aJs7aZRCAjFLNk%3D&
> reserved=0 - uses language like "...a form of rank...which renders
> much of a program's control structure implicit by lifting base
> operators to higher-dimensional array structures." I will have to include
> this in the references to use it but was hoping to find an older document,
> preferably one already in the references, but have been stymied by the lack
> of explicit reference to avoiding loops by using rank because it seems so
> obvious that it is only implied.
> > In any case, a reference to the assertions about "map" and such
> > would
> also be appreciated.
> > Thanks,
> > Devon
> > Sent from my Verizon, Samsung Galaxy smartphone
> > --------------------------------------------------------------------
> > -- For information about J forums see
> > https://eur04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww
> > .jsoftware.com%2Fforums.htm&data=02%7C01%7C%7C91964909f04b4d32b1
> > cf08d633c3cb94%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C63675331
> > 3359613565&sdata=feXUcOi1wNIx781R9evv8qB2qPls1qqG4IOl6TpudSA%3D&
> > amp;reserved=0
>
>
> ----------------------------------------------------------------------
> For information about J forums see
> https://eur04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.j
> software.com%2Fforums.htm&data=02%7C01%7C%7C91964909f04b4d32b1cf08
> d633c3cb94%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C63675331335961
> 3565&sdata=feXUcOi1wNIx781R9evv8qB2qPls1qqG4IOl6TpudSA%3D&rese
> rved=0
> ----------------------------------------------------------------------
> For information about J forums see
> https://eur04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.j
> software.com%2Fforums.htm&data=02%7C01%7C%7C91964909f04b4d32b1cf08
> d633c3cb94%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C63675331335961
> 3565&sdata=feXUcOi1wNIx781R9evv8qB2qPls1qqG4IOl6TpudSA%3D&rese
> rved=0
----------------------------------------------------------------------
For information about J forums see
https://eur04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=02%7C01%7C%7C91964909f04b4d32b1cf08d633c3cb94%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636753313359613565&sdata=feXUcOi1wNIx781R9evv8qB2qPls1qqG4IOl6TpudSA%3D&reserved=0
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm