## Still strugling

5 posts
• Page

**1**of**1**### Still strugling

5⌈2 + 8⌈14 gives 16

but

2 + 8⌈14 gives also 16

That first 5 does not do anything ?

but 5⌈2 gives 5 ??

So I would expect 5 + 14 gives 19

----------------------------------------------

Same confusing thing :

4×2 5+3 gives 20 32

Simply don't see how to come to this.

Feeling very dumb. Sorry.

-----------------------------------------------

Ah , the first I got (I think)

first 8⌈14 = 14. Then 2 + 14 = 16. then 5⌈16 = 16 !! Correct ?

----------------------------------------------

The second one (4×2 5+3) I can only solve when I get rid of the "right to left" rule !

2 5+3 = 5 8. thus first 2+3 then 5+3 ?? thus not 5+3 first ? 4× 5 8 = 20 32

but

2 + 8⌈14 gives also 16

That first 5 does not do anything ?

but 5⌈2 gives 5 ??

So I would expect 5 + 14 gives 19

----------------------------------------------

Same confusing thing :

4×2 5+3 gives 20 32

Simply don't see how to come to this.

Feeling very dumb. Sorry.

-----------------------------------------------

Ah , the first I got (I think)

first 8⌈14 = 14. Then 2 + 14 = 16. then 5⌈16 = 16 !! Correct ?

----------------------------------------------

The second one (4×2 5+3) I can only solve when I get rid of the "right to left" rule !

2 5+3 = 5 8. thus first 2+3 then 5+3 ?? thus not 5+3 first ? 4× 5 8 = 20 32

- hbarkhof
**Posts:**44**Joined:**Mon Apr 09, 2018 8:37 am

### Re: Still strugling

Yes, you got the first one.

Regarding the second one, the 2 and the 5 bind together first, to form a 2-element vector. This is called strand notation, and it takes precedence over function application (I think that is the right terminology, but I will be corrected soon enough below if not). Treat this as one thing, and then use the right to left rule - so the first thing that happens is 2 5+3 which yields the two element vector 5 8.

Regarding the second one, the 2 and the 5 bind together first, to form a 2-element vector. This is called strand notation, and it takes precedence over function application (I think that is the right terminology, but I will be corrected soon enough below if not). Treat this as one thing, and then use the right to left rule - so the first thing that happens is 2 5+3 which yields the two element vector 5 8.

- paulmansour
**Posts:**430**Joined:**Fri Oct 03, 2008 4:14 pm

### Re: Still strugling

Try putting parens around until you get the hang of it. It's not crazy, just different. Here are the strand (vector) notation rules from the Programmer's Guide:

The tricky case might be when using variable names (whether on their own or mixed with constants), as in this case:

A series of two or more adjacent expressions results in a vector whose elements are the enclosed arrays resulting from each expression. This is known as VECTOR (or STRAND) NOTATION. Each expression in the series may consist of one of the following:

a. a single numeric value;

b. single character, within a pair of quotes;

c. more than one character, within a pair of quotes;

d. the name of a variable;

e. the evaluated input symbol ⎕;

f. the quote-quad symbol ⍞;

g. the name of a niladic, defined function yielding a result;

h. any other APL expression which yields a result, within parentheses.

The tricky case might be when using variable names (whether on their own or mixed with constants), as in this case:

- Code: Select all
`A B C D E F←1 2 3 4 5 6`

A B C + D E F

5 7 9

(A B C) + (D E F)

5 7 9

A B (C + D) E F

1 2 7 5 6

- petermsiegel
**Posts:**159**Joined:**Thu Nov 11, 2010 11:04 pm

### Re: Still strugling

Hi,

perhaps the easiest way to grasp this is to use parentheses (from right to left), e.g.

Remember that the vector binding is stronger than function binding, thus

And last: don't ever use multiple assignment without parentheses (avoiding problems, e.g understanding the code afterwards), that's an unnecessary and irritating anomaly. The expression

may be interpreted as function Foo with two arguments set at once, or assigning three variables, or assigning the right argument for function Goo, or..

This becomes more hairy with namespaces, with []PATH *sigh*.

But writing

is safe, and clear, and logical.

-wm

perhaps the easiest way to grasp this is to use parentheses (from right to left), e.g.

5⌈(2+(8⌈14))

16

5⌈(2+ 8⌈14 )

16

5⌈ 2+ 8⌈14

16

Remember that the vector binding is stronger than function binding, thus

4×((2 5)+3)

20 32

4× (2 5)+3

20 32

4× 2 5 +3

20 32

And last: don't ever use multiple assignment without parentheses (avoiding problems, e.g understanding the code afterwards), that's an unnecessary and irritating anomaly. The expression

Foo Goo Hoo←...

may be interpreted as function Foo with two arguments set at once, or assigning three variables, or assigning the right argument for function Goo, or..

This becomes more hairy with namespaces, with []PATH *sigh*.

But writing

(Foo Goo Hoo)←...

is safe, and clear, and logical.

-wm

- Veli-Matti
**Posts:**94**Joined:**Sat Nov 28, 2009 3:12 pm

### Re: Still strugling

Thanks a lot , Gents. I think I got it. Very good tip to use parentheses !

- hbarkhof
**Posts:**44**Joined:**Mon Apr 09, 2018 8:37 am

5 posts
• Page

**1**of**1**### Who is online

Users browsing this forum: No registered users and 0 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group