Page 2 of 2

Re: Intuition, aesthetics and performance

Posted: Tue Feb 23, 2010 9:21 am
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.

Re: Intuition, aesthetics and performance

Posted: Wed Feb 24, 2010 9:36 am
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.

Re: Intuition, aesthetics and performance

Posted: Wed Feb 24, 2010 1:27 pm
by MikeHughes
I also like that but was confused by

↑'-'{⍺,⍺⍺,'E',⍵,'D'}/'now' 'is' 'the' 'time'
giving
now-Eis-Ethe-EtimeDDD

Re: Intuition, aesthetics and performance

Posted: Wed Feb 24, 2010 1:35 pm
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.

Re: Intuition, aesthetics and performance

Posted: Wed Feb 24, 2010 2:53 pm
by MikeHughes
Sorry Im a pratt of course you are right - I fell off a lorry last week - still havent recovered fully obviously :-D