Options with Variant ⍠
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 !
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 !
7 posts
• Page 1 of 1
Options with Variant ⍠
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
(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: 143
- Joined: Thu Nov 11, 2010 11:04 pm
Re: Options with Variant ⍠
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.
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.
-
Richard|Dyalog - Posts: 44
- Joined: Thu Oct 02, 2008 11:11 am
Re: Options with Variant ⍠
And I sit here and wait patiently for it to arrive!
Okay then: I want it, all, and now!
Okay then: I want it, all, and now!
-
kai - Posts: 137
- Joined: Thu Jun 18, 2009 5:10 pm
- Location: Hillesheim / Germany
Re: Options with Variant ⍠
In the mean time, is there some mileage for primitives with bespoke namespaces:
So whenever a variant of a primitive is required
- 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.
Please excuse any smelling pisstakes.
-
ray - Posts: 221
- Joined: Wed Feb 24, 2010 12:24 am
- Location: Blackwater, Camberley. UK
Re: Options with Variant ⍠
If we introduce the namespace notation I presented at Dyalog '17 you could write:
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.
(⎕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.
-
Adam|Dyalog - Posts: 135
- Joined: Thu Jun 25, 2015 1:13 pm
Re: Options with Variant ⍠
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 ##.
I presume names in the environment in which the namespace was created can be picked up using ##.
- petermsiegel
- Posts: 143
- Joined: Thu Nov 11, 2010 11:04 pm
Re: Options with Variant ⍠
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)
-
Adam|Dyalog - Posts: 135
- Joined: Thu Jun 25, 2015 1:13 pm
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group