Yoda-speak?
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 !
11 posts
• Page 1 of 2 • 1, 2
Yoda-speak?
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" :-).
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?
Hi John,
I read
but parse it as "n is greater than zero"
while
I read
but parse it as "zero is less than n".
But then I am dyslexic, and "Today is Saturday".
Ray
I read
- Code: Select all
0<n
but parse it as "n is greater than zero"
while
I read
- Code: Select all
n>0
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.
Please excuse any smelling pisstakes.
-
ray - Posts: 221
- Joined: Wed Feb 24, 2010 12:24 am
- Location: Blackwater, Camberley. UK
Re: Yoda-speak?
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.
Sunday today is.
- JohnS|Dyalog
Re: Yoda-speak?
- but not in all languages.but people read it left-to-right
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
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.
Please excuse any smelling pisstakes.
-
ray - Posts: 221
- Joined: Wed Feb 24, 2010 12:24 am
- Location: Blackwater, Camberley. UK
Re: Yoda-speak?
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?
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."six divided by: four minus two".
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!
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
Re: Yoda-speak?
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 ..
-
AndyS|Dyalog - Posts: 257
- Joined: Tue May 12, 2009 6:06 pm
Re: Yoda-speak?
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÷4as (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?
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
For example, I have been writing
i←1+isince forever. Most people would write i←i+1.
- Roger|Dyalog
- Posts: 238
- Joined: Thu Jul 28, 2011 10:53 am
Re: Yoda-speak?
"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
in addition, putting the more "complex" item on the left may require extra parentheses.put "simpler" things on the left
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.
Please excuse any smelling pisstakes.
-
ray - Posts: 221
- Joined: Wed Feb 24, 2010 12:24 am
- Location: Blackwater, Camberley. UK
11 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group