bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] IOTA


From: Christian Robert
Subject: Re: [Bug-apl] IOTA
Date: Tue, 1 Mar 2016 21:43:08 -0500
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

I see, but what is the "/" doing ?

Xtian

      {⍳¨⍵} 1
┌───┐
│┌→┐│
││1││
│└─┘│
└∊──┘
      {⍳¨⍵} 1 2
┌2────────┐
│┌→┐ ┌2──┐│
││1│ │1 2││
│└─┘ └───┘│
└∊────────┘
      {⍳¨⍵} 1 2 3
┌3────────────────┐
│┌→┐ ┌2──┐ ┌3────┐│
││1│ │1 2│ │1 2 3││
│└─┘ └───┘ └─────┘│
└∊────────────────┘
      {∘.,/⍳¨⍵} 1 2 3
┌─────────────────────────┐
│┌3──────────────────────┐│
│1┌3────┐ ┌3────┐ ┌3────┐││
│││1 1 1│ │1 1 2│ │1 1 3│││
│2└─────┘ └─────┘ └─────┘││
││┌3────┐ ┌3────┐ ┌3────┐││
│││1 2 1│ │1 2 2│ │1 2 3│││
││└─────┘ └─────┘ └─────┘││
│└∊──────────────────────┘│
└∊∊───────────────────────┘
      {⊃∘.,/⍳¨⍵} 1 2 3
┌3──────────────────────┐
1┌3────┐ ┌3────┐ ┌3────┐│
││1 1 1│ │1 1 2│ │1 1 3││
2└─────┘ └─────┘ └─────┘│
│┌3────┐ ┌3────┐ ┌3────┐│
││1 2 1│ │1 2 2│ │1 2 3││
│└─────┘ └─────┘ └─────┘│
└∊──────────────────────┘


On 2016-03-01 21:23, Elias Mårtenson wrote:
Looking at it further, I realise you need do disclose the result in order to 
make them equivalent:

*      IOTA ← {⊃∘.,/⍳¨⍵}*

Regards,
Elias

On 2 March 2016 at 10:19, Elias Mårtenson <address@hidden 
<mailto:address@hidden>> wrote:

    I don't know about a loop, but wouldn't this do the same thing?

    *    IOTA ← {∘.,/⍳¨⍵}*

    Regards,
    Elias

    On 2 March 2016 at 09:57, Christian Robert <address@hidden 
<mailto:address@hidden>> wrote:

        I have this function,

               ∇IOTA[⎕]∇
             ∇
        [0]   z←IOTA v
        [1]   z←⍳↑v
        [2]   v←1↓,v
        [3]  Loop: →(0=⍴v)/0
        [4]   z←z∘.,⍳↑v
        [5]   v←1↓v
        [6]   →Loop
             ∇

               ]boxing 24

               IOTA 0
        ┌⊖┐
        │0│
        └─┘
               IOTA 10
        ┌10──────────────────┐
        │1 2 3 4 5 6 7 8 9 10 <tel:1%202%203%204%205%206%207%208%209%2010>│
        └────────────────────┘
               IOTA 2 3
        ┌3────────────────┐
        2┌2──┐ ┌2──┐ ┌2──┐│
        ││1 1│ │1 2│ │1 3││
        │└───┘ └───┘ └───┘│
        │┌2──┐ ┌2──┐ ┌2──┐│
        ││2 1│ │2 2│ │2 3││
        │└───┘ └───┘ └───┘│
        └∊────────────────┘
               IOTA 2 3 5
        ┌5──────────────────────────────────────┐
        2┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐│
        ││1 1 1│ │1 1 2│ │1 1 3│ │1 1 4│ │1 1 5││
        3└─────┘ └─────┘ └─────┘ └─────┘ └─────┘│
        │┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐│
        ││1 2 1│ │1 2 2│ │1 2 3│ │1 2 4│ │1 2 5││
        │└─────┘ └─────┘ └─────┘ └─────┘ └─────┘│
        │┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐│
        ││1 3 1│ │1 3 2│ │1 3 3│ │1 3 4│ │1 3 5││
        │└─────┘ └─────┘ └─────┘ └─────┘ └─────┘│
        │                                       │
        │┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐│
        ││2 1 1│ │2 1 2│ │2 1 3│ │2 1 4│ │2 1 5││
        │└─────┘ └─────┘ └─────┘ └─────┘ └─────┘│
        │┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐│
        ││2 2 1│ │2 2 2│ │2 2 3│ │2 2 4│ │2 2 5││
        │└─────┘ └─────┘ └─────┘ └─────┘ └─────┘│
        │┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐ ┌3────┐│
        ││2 3 1│ │2 3 2│ │2 3 3│ │2 3 4│ │2 3 5││
        │└─────┘ └─────┘ └─────┘ └─────┘ └─────┘│
        └∊──────────────────────────────────────┘



        my question is: can such a function can be written in Lambda style ? 
(especially in gnuapl)

        eg:

        IOTA ← { ... }

        That IOTA function simulate the behavior of "⍳" on "Dyalog APL" and 
NARS2000 and more interpretors when the argument is a vector.


        thanks,

        Xtian.








reply via email to

[Prev in Thread] Current Thread [Next in Thread]