TAO
4 posts
• Page 1 of 1
TAO
Now that we have TAO, certain other functions suggest themselves. For example, if I want to know if one general array is less than or equal to another general array I might do something like:
In fact, I think there is a dfn in the dfns ws that models this, and on which some of TAO was based. (It's a lot easier to code it now!)
Or if I want the minimum of two general arrays I might do:
Or the max reduction:
The relationship to their scalar counterparts seem analogous to match and equals; a set of functions that are similar to scalar functions, but work on items, rather than scalars. We might call them item functions.
I'm sure I'm not the first to realize this, and somebody has neatly coded up a nice, consistent library?
le←{
(⍳2)≡⍋⍺ ⍵
}
In fact, I think there is a dfn in the dfns ws that models this, and on which some of TAO was based. (It's a lot easier to code it now!)
Or if I want the minimum of two general arrays I might do:
min←{
(⍺ le ⍵)⊃⍵ ⍺
}
Or the max reduction:
maxr←{
(⊃⍒⍵)⊃⍵
}
The relationship to their scalar counterparts seem analogous to match and equals; a set of functions that are similar to scalar functions, but work on items, rather than scalars. We might call them item functions.
I'm sure I'm not the first to realize this, and somebody has neatly coded up a nice, consistent library?
 paulmansour
 Posts: 282
 Joined: Fri Oct 03, 2008 4:14 pm
Re: TAO
Is it worth considering an eachless approach, so that le above could take equal shaped arrays on each side, and compare the items at once? Or are we then forced to enclose things all the time when just comparing two arrays? I suppose that bridge is already crossed with respect to match.
 paulmansour
 Posts: 282
 Joined: Fri Oct 03, 2008 4:14 pm
Re: TAO
In a sense ≡ and ≢ are more fundamental than = and ≠ in that the latter can be defined as pervasive forms of the former. Let's denote pervasiveness using a depth operator f⍥0 which is analogue to f⍤0 but applies f to subarrays of depth 0 rather than subarrays of rank 0. So = is ≡⍥0 and ≠ is ≢⍥0. See http://dfns.dyalog.com/n_Depth.htm
What you are first suggesting is the set of functions which are to < ≤ ≥ > what ≡ and ≢ are to = and ≠. The traditional symbols for these four functions are ≺ ≼ ≽ ≻ (these have curved strokes). Thus < ≤ ≥ > are ≺⍥0 ≼⍥0 ≽⍥0 ≻⍥0.
These four functions (together with ≡ and ≢) can also define your second proposal with f⍤¯1 (this uses the existing rank operator).
Question is of course if it is worth four additional symbols to get these fundamental comparison functions. Do you actually need them or are they just useful to understand comparison in general? What we can do without it costing any symbols is to extend < ≤ = ≥ > ≠ to be ≺⍥0 ≼⍥0 ≡⍥0 ≽⍥0 ≻⍥0 ≢⍥0. Indeed, I have done exactly that in my "Dyalog APL Extended" library, https://github.com/abrudz/dyalogaplextended
What you are first suggesting is the set of functions which are to < ≤ ≥ > what ≡ and ≢ are to = and ≠. The traditional symbols for these four functions are ≺ ≼ ≽ ≻ (these have curved strokes). Thus < ≤ ≥ > are ≺⍥0 ≼⍥0 ≽⍥0 ≻⍥0.
These four functions (together with ≡ and ≢) can also define your second proposal with f⍤¯1 (this uses the existing rank operator).
Question is of course if it is worth four additional symbols to get these fundamental comparison functions. Do you actually need them or are they just useful to understand comparison in general? What we can do without it costing any symbols is to extend < ≤ = ≥ > ≠ to be ≺⍥0 ≼⍥0 ≡⍥0 ≽⍥0 ≻⍥0 ≢⍥0. Indeed, I have done exactly that in my "Dyalog APL Extended" library, https://github.com/abrudz/dyalogaplextended

AdamDyalog  Posts: 52
 Joined: Thu Jun 25, 2015 1:13 pm
Re: TAO
I don't think it is worth 4 symbols, (and there is also max and min), but they are easy enough to cover, and they are indeed practical. In fact, if TAO sorting has any practical use, why wouldn't these?
My immediate use case is a numeric triple representing a software version, e.g., 2 1 7 or 1 3 12. Give any two versions, I need to know which is higher, or to select the higher one. Given a list of them, I need to know the highest, etc.
I looked at your covers in Dyalog Extended Library. Theses appear to me less useful than the curved stroke versions. Unless I am missing something, they are still scalar functions, they simply extend the domain to characters. Correct? Do you have an example of use case for them? Of course since they don't use up a symbol, they may be worth having anyway.
A specific question: you noted:
Can you give me an example of this?
My immediate use case is a numeric triple representing a software version, e.g., 2 1 7 or 1 3 12. Give any two versions, I need to know which is higher, or to select the higher one. Given a list of them, I need to know the highest, etc.
I looked at your covers in Dyalog Extended Library. Theses appear to me less useful than the curved stroke versions. Unless I am missing something, they are still scalar functions, they simply extend the domain to characters. Correct? Do you have an example of use case for them? Of course since they don't use up a symbol, they may be worth having anyway.
A specific question: you noted:
These four functions (together with ≡ and ≢) can also define your second proposal with f⍤¯1 (this uses the existing rank operator).
Can you give me an example of this?
 paulmansour
 Posts: 282
 Joined: Fri Oct 03, 2008 4:14 pm
4 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