Intuition, aesthetics and performance

General APL language issues
JohnS|Dyalog

Re: Intuition, aesthetics and performance

Post by JohnS|Dyalog »

Regarding a {⍺,⍺⍺,⍵}/ idiom:

I like the idea because it would turn an intuitive way to write this interleaving from an n-squared into a linear algorithm. I have logged an RFE (ref 5750) to this effect.

However, {⍺,⍺⍺,⍵}/ is an incomplete expression (a conjunction of two operators) and so could not be named. We might have to consider a more complex idiom:

Code: Select all

      sandwich ← {↑⍺{⍺,⍺⍺,⍵}/⍵}    ⍝ sandwich idiom.

      '-' sandwich 'now' 'is' 'the' 'time'
now-is-the-time

John.
JohnS|Dyalog

Re: Intuition, aesthetics and performance

Post by JohnS|Dyalog »

John'S £2E¯2J0's worth regarding ⎕PATH:

I think there are broadly two markets for a name-finding mechanism.

[1] The first is global and is used to locate utility functions from within any namespace. It is handy to be able to type "display" at the front of an expression, or inject "time" between a function and it's argument, irrespective of where I am in the namespace hierarchy.

[2] The second is more like a language "include" statement and is specific to a particular namespace.

⎕PATH implements the first of these; it is modelled on the opsys library path concept, where, happily, DIR, ls and pwd mean the same wherever I happen to be :-)

V12.1's user-command system: ]display, &co have to some extent replaced the need for [1].

We don't have an equivalent mechanism for [2]. Perhaps we should.
User avatar
MikeHughes
Posts: 86
Joined: Thu Nov 26, 2009 9:03 am
Location: Market Harborough, Leicestershire, UK

Re: Intuition, aesthetics and performance

Post by MikeHughes »

I also like that but was confused by

↑'-'{⍺,⍺⍺,'E',⍵,'D'}/'now' 'is' 'the' 'time'
giving
now-Eis-Ethe-EtimeDDD
User avatar
Phil Last
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: Intuition, aesthetics and performance

Post by Phil Last »

MikeHughes wrote:↑'-'{⍺,⍺⍺,'E',⍵,'D'}/'now' 'is' 'the' 'time'


In any expression:
      ⊃{... ⍵ ...}/list

⍵ is the result so far from all iterations. In the above case first it's 'time' then the result from 'the'{...}'time' and so on.

Catenating your 'D' to the right of ⍵ means they're all going to be tacked on the end.
User avatar
MikeHughes
Posts: 86
Joined: Thu Nov 26, 2009 9:03 am
Location: Market Harborough, Leicestershire, UK

Re: Intuition, aesthetics and performance

Post by MikeHughes »

Sorry Im a pratt of course you are right - I fell off a lorry last week - still havent recovered fully obviously :-D
Post Reply