2

In the K language, an operator can be suffixed with an apostrophe to apply to each element in an array:

  8 +' 2 4 10
10 12 18
  9 <' 3 10 2
0 1 0
  8 -' 1 7 10
7 1 -2

However, in each of those cases, the apostrophe is not required, because these dyadic verbs naturally apply across the array:

  8 + 2 4 10
10 12 18
  9 < 3 10 2
0 1 0
  8 - 1 7 10
7 1 -2

The only place I have yet seen there to be a difference is with the ! verb, which applies the modulo operation for each element of the array when decorated with ' but acts as a rotate when not decorated:

  3 !' 1 2 3 4 5
0 1 0 3 3
  3 ! 1 2 3 4 5
4 5 1 2 3

Are there any other places in K where the decorated (apostrophe-d) version of a verb is different from the undecorated case? (I'm new to K so very likely am missing such cases!)

Ray Toal
  • 86,166
  • 18
  • 182
  • 232

2 Answers2

2

Lots of places, especially once you start dealing with your own functions:

  {"go",x} ("";"ing";"ne")
"g"
"o"
""
"ing"
"ne"

  {"go",x}' ("";"ing";"ne")
"go"
"going"
"gone"

(you might prefer to write that as ,["go"]')

tangentstorm
  • 7,183
  • 2
  • 29
  • 38
2

My personal favorite use of each is for doing a mingle:

1 2 3 ,' 4 5 6 (1 4;2 5;3 6)

ein mensch
  • 311
  • 2
  • 9