Options with Variant ⍠

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

Options with Variant ⍠

Postby petermsiegel on Tue Jun 19, 2018 3:06 am

Any thought about opening up the use of Variant ⍠ with user-defined functions?

(Myplot ⍠ ‘Title’ ‘my plot title’ ⍠ ‘missing’ ¯1) xvals yvals

or even with Perl-esque syntactic sugar (where the magical behaviour of such a → may offend syntax purists)

(Myplot ⍠ Title → ‘my plot title’ ⍠ missing → ¯1) xvals yvals

How about with built-ins like iota?

(⍳⍠⎕IO → 1) 100 ⍝ {⎕IO ← 1 ⋄ ⍳⍵} 100
petermsiegel
 
Posts: 141
Joined: Thu Nov 11, 2010 11:04 pm

Re: Options with Variant ⍠

Postby Richard|Dyalog on Tue Jul 10, 2018 12:21 pm

Peter - apologies for not responding to this sooner.

Yes - variant was designed with the expectation it would be applied to more and more functions in future, including user-defined ones. When it was first being put together we also produced a "Conference Edition" release of Dyalog for the 2011 User Meeting, in order to demonstrate some experimental functionality including variant support on iota (both monadic and dyadic), though its reception was "mixed". Indeed, variant is in general quite divisive - I am keen on it, but some (both within Dyalog and without) are not and even though the idea of extending it to user functions does resurface from time to time, I cannot give any promise we will ever do it. If we did, I would not expect any change in the existing syntax.
User avatar
Richard|Dyalog
 
Posts: 44
Joined: Thu Oct 02, 2008 11:11 am

Re: Options with Variant ⍠

Postby kai on Tue Jul 10, 2018 2:10 pm

And I sit here and wait patiently for it to arrive!

Okay then: I want it, all, and now!
User avatar
kai
 
Posts: 137
Joined: Thu Jun 18, 2009 5:10 pm
Location: Hillesheim / Germany

Re: Options with Variant ⍠

Postby ray on Tue Aug 07, 2018 12:33 pm

In the mean time, is there some mileage for primitives with bespoke namespaces:
Code: Select all
    'io0' 'ml2'   ⎕SE.⎕NS¨'' ''
     ⎕SE.io0.⎕IO←0
     ⎕SE.ml2.⎕ML←2

So whenever a variant of a primitive is required
Code: Select all
   )clear
clear ws

     ↑⍳8
1 2 3 4 5 6 7 8
     ⊃⍳8
1

⍝ with tongue slightly in cheek

     ⎕SE.ml2.↑ ⎕SE.io0.⍳ 8
0
     ⎕SE.ml2.⊃ ⎕SE.io0.⍳ 8
0 1 2 3 4 5 6 7
 
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 221
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Re: Options with Variant ⍠

Postby Adam|Dyalog on Sun Aug 12, 2018 8:34 am

If we introduce the namespace notation I presented at Dyalog '17 you could write:
      (⎕IO:0).⍳8
0 1 2 3 4 5 6 7
(⎕ML:2).↑⍳8
1
(⎕ML:2⋄⎕IO:0).(↑⍳8)
0

A benefit is that all other settings will be picked up from the host namespace. Only watch out for inaccessibility of names, ⎕RL staying fixed, and related issues.
User avatar
Adam|Dyalog
 
Posts: 135
Joined: Thu Jun 25, 2015 1:13 pm

Re: Options with Variant ⍠

Postby petermsiegel on Thu Sep 06, 2018 12:33 am

Thumbs up on the notation you presented. An elegant and intuitive solution to a number of problems.

I presume names in the environment in which the namespace was created can be picked up using ##.
petermsiegel
 
Posts: 141
Joined: Thu Nov 11, 2010 11:04 pm

Re: Options with Variant ⍠

Postby Adam|Dyalog on Thu Sep 06, 2018 7:26 am

Yes, you can pick up names from the parent space with ##.names but inside the new notation, you can also refer to parent names directly:

      Var1←42
Fn1←+⌿÷≢
NewSpace←(Var2:Var1×2 ⋄ Fn1:Fn1)
User avatar
Adam|Dyalog
 
Posts: 135
Joined: Thu Jun 25, 2015 1:13 pm


Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest