kevinlawler / kona

Open-source implementation of the K programming language
ISC License
1.36k stars 138 forks source link

Error on docs example of each-right #602

Closed traws0 closed 3 years ago

traws0 commented 3 years ago

Windows release.

\'
...
/: eachright    #:/:(2;2 2;2 2 2)    count each right
/: eachright    2 #/: ("alpha";"bravo";"charlie")    take each right
\: eachleft     0 1 2 3 #\: "abc"     take each left
': eachpair     apply pairwise  -':1 3 4 8 10
  #:/:(2;2 2;2 2 2)
valence error
tavmem commented 3 years ago

Thanks !! You're right ... the documentation needs to be fixed.

Versions of kona as recent as 03-Oct-2019 did give a result: $ cd k191003 $ rlwrap -n ./k kona \ for help. \ to exit.

:/:(2;2 2;2 2 2)

1 2 3

However, this was "fixed" in kona to correspond with the result given in k2.8 and k3.2: $ cd k2.8 $ rlwrap -n ./k K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems Evaluation. Not for commercial use. \ for help. \ to exit.

:/:(2;2 2;2 2 2)

valence error

:/:(2;2 2;2 2 2)

^

bakul commented 3 years ago

Many cases can make do with just each. No need for each-right. One instance is the example used for each-right!

2 #/: ("alpha";"bravo";"charlie") 

This doesn't require each-right and the following works just as well

2 # ' ("alpha";"bravo";"charlie")

You can use each right for something like this:

2 2 #/: ("alpha";"bravo";"charlie") 

But even here

(2 2 #) ' ("alpha";"bravo";"charlie")