Yoda-speak?

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 !

Yoda-speak?

Postby JohnS|Dyalog on Fri Feb 02, 2018 12:22 pm

Is it just me or is 0<n harder to grok than n>0?
I appreciate the brevity of 0<≢v compared with (≢v)>0.
Note that 0=⍺⍺ could be a fork, whereas ⍺⍺=0 can't, so the latter is simpler.
An APLer is someone who says "Friday is today" :-).
JohnS|Dyalog
 

Re: Yoda-speak?

Postby ray on Sat Feb 03, 2018 3:33 pm

Hi John,

I read
Code: Select all
0<n
as "zero is less than n "
but parse it as "n is greater than zero"
while
I read
Code: Select all
n>0
as "n is greater than zero"
but parse it as "zero is less than n".

But then I am dyslexic, and "Today is Saturday".

Ray
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: Yoda-speak?

Postby JohnS|Dyalog on Sun Feb 04, 2018 2:00 pm

Interesting. I'm hazy about the distinction between "read", "parse" and "understand". Many years ago I was involved in an APL implementation in which we had to decide between semicolon (Sigma APL) and diamond (IPSA) statement separators. Semicolon-separated statements are evaluated right-to-left whilst diamond statements, as in Dyalog, left-to-right. I wrote to Floy Ivie, who implemented Sigma APL, for guidance. He recommended using diamond because "the machine evaluates APL right-to-left but people read it left-to-right". I wonder if that's true.
Sunday today is.
JohnS|Dyalog
 

Re: Yoda-speak?

Postby ray on Sun Feb 04, 2018 5:25 pm

but people read it left-to-right
- but not in all languages.

I note the definition in the Dyalog APL reference manual of < is the "Less Than Sign". When the smaller number is to the left, the result is "true".
When combined in an :If control structure, the English reading is from left to right.
Code: Select all
:If 0<N
it directly translate into English as
If zero is less than N


Although I really like control structures in APL as they make it easier to layout and format APL functions, resulting in (for English speaking programmers at least) easier to read code, I do believe they dilute the beauty of APL, (just as Dfns enhance it).

I'm glad you implemented the diamond separator as you did, otherwise

Code: Select all
:Endif ; 'true' ; :If 0<n


I also note that guards in Dfns read from left to right.

Control structures and reserved words, employ ENGLISH words, and by extension impose the left to right (and top to bottom) reading. APL written without the use of English reserved words allows one to read the code from right to left, so this might be more natural for coders brought up reading say Arabic or Hebrew.

So, might there be a case for facilitating APL to be entered also from right to left?

(Both Roman and Arabic numbers reading left to right, go from hight to low. Is that big-endian?)

Is today Monday?
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: Yoda-speak?

Postby JohnS|Dyalog on Sun Feb 04, 2018 7:52 pm

I wonder what proportion of us understand 6÷4-2 as "six divided by: four minus two" and how many of us think "two subtracted from four, divided into six".
JohnS|Dyalog
 

Re: Yoda-speak?

Postby Phil Last on Sun Feb 04, 2018 11:58 pm

"six divided by: four minus two".
The colon doesn't do it for me. "..." is often used to indicate something missing but I'm not aware of a punctuation symbol for a pregnant pause.

I don't have a problem with things like `0<n` vs `n>0` but I came across a bit of my own code tonight that took me aback for a moment
      ⍺ f00 3⍴⍺ f01 ⍵
f01 is not restricted to a 3-item left argument!
User avatar
Phil Last
 
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: Yoda-speak?

Postby AndyS|Dyalog on Mon Feb 05, 2018 9:21 am

I'd agree with your original premise, but then remember that I was taught that 1=n is preferable to n=1 since in some programming languages you're in danger of assigning the value 1 to n. Therefore the argument goes that for the sake of consistency if you're going to have 1=n, then you should have 1<n .. at which point I get a headache and do whatever seems easiest ..
User avatar
AndyS|Dyalog
 
Posts: 257
Joined: Tue May 12, 2009 6:06 pm

Re: Yoda-speak?

Postby JohnS|Dyalog on Mon Feb 05, 2018 9:41 am

I don't have a problem with things like `0<n` vs `n>0` but I came across a bit of my own code tonight that took me aback for a moment
⍺ f00 3⍴⍺ f01 ⍵
f01 is not restricted to a 3-item left argument!

Newbies often read:
      1÷2 3÷4
as (1÷2)(3÷4)

In the test scripts in dfns.dws I've taken to leaving a gap between a dyadic primitive function and its right argument:
      6÷ 4- 2
0= ⎕nc'...
⍺ f00 3⍴ ⍺ f01 ⍵
JohnS|Dyalog
 

Re: Yoda-speak?

Postby Roger|Dyalog on Mon Feb 05, 2018 11:13 am

I write 0<n instead of n>0, an instance of a general rule I have been applying since the earliest days of my APL use, namely put "simpler" things on the left.

For example, I have been writing
      i←1+i
since forever. Most people would write i←i+1.
Roger|Dyalog
 
Posts: 238
Joined: Thu Jul 28, 2011 10:53 am

Re: Yoda-speak?

Postby ray on Mon Feb 05, 2018 4:55 pm

"six divided by: four minus two".

The colon doesn't do it for me.

As APL'ers we like to removed any redundant parentheses, but "six divided by (four minus two)" is unambiguous.

But then I like Roger's
put "simpler" things on the left
in addition, putting the more "complex" item on the left may require extra parentheses.

However
Code: Select all
i←1+i
⍝ rather than
i←i+1
⍝ may stop one from noticing the possibility
i+←1

Some coding styles make the code easier to spot patterns in and understand, as a result easier to re-factor and maintain.
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 221
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Next

Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest