I too expected what you did, but found the behaviour to be what it is.
Everyone before us, perhaps found the same. Its not a crazy implementation.
A better example of a surprise is with 4 items. But the root of all of this
lies in what to do with 2 items.
+`*/3 4 5 2
31
+`*`-/3 4
7
*`+`*`-/ i.0
1
----- Original Message -----
From: Raul Miller <[email protected]>
To: Programming forum <[email protected]>
Sent: Monday, February 22, 2016 4:21 PM
Subject: [Jprogramming] Am I understanding m/y ?
http://www.jsoftware.com/help/dictionary/d420.htm says:
m/y inserts successive verbs from the gerund m between items of y,
extending m cyclically as required. Thus, +`*/i.6 is 0+1*2+3*4+5
But it does not include an example of m/y where y contains an odd
number of elements.
From the description, I would expect +`*/3 4 5 to give the result 3*4+5
However:
3*4+5
27
+`*/3 4 5
23
I'm thinking that this might be a bug in the interpreter.
Is there some application, though, that requires the current behavior?
Thanks,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm