Skip to content

Commit 3eb137f

Browse files
authored
Merge pull request #412 from gyorokpeter/append_enum
add info about joining enums
2 parents 28bbe76 + 91ef7a2 commit 3eb137f

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

docs/ref/join.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,37 @@ q)v,(type v)$0xab
4747
1.00 2.34 -567.1 20.00 171e
4848
```
4949

50+
The result is a general list if the two arguments are [enumeration](enumerate.md) atoms of different domains, or one is an enumeration and the other is a regular symbol:
51+
52+
```q
53+
q)sym:`a`b
54+
q)sym2:`c`d
55+
q)(`sym$`b),`sym2$`b
56+
`sym$`b
57+
`sym2$`b
58+
q)(`sym$`b),`b
59+
`sym$`b
60+
`b
61+
q)`b,(`sym$`b)
62+
`b
63+
`sym$`b
64+
```
65+
66+
On the other hand, if either or both arguments are lists and not of the same enumeration domain, any enumerations are de-enumerated:
67+
68+
```q
69+
q)(`sym$`a`b),`sym2$`b`c
70+
`a`b`b`c
71+
q)(`sym$`a),`c`d
72+
`a`c`d
73+
q)(`sym$`a`b),`c
74+
`a`b`c
75+
q)`a,`sym2$`b`c
76+
`a`b`c
77+
q)`a`b,`sym2$`c
78+
`a`b`c
79+
```
80+
5081
`,`(join) is a [multithreaded primitive](../kb/mt-primitives.md).
5182

5283

@@ -160,6 +191,30 @@ q)s
160191
4 5 6
161192
```
162193

194+
If `x` contains an enumeration, append will enumerate `y` against `x`'s domain, which may fail if the appended symbols are not in that domain:
195+
196+
```q
197+
q)sym:`a`b
198+
q)e:`sym$`a`b
199+
q)e,:`b
200+
q)e
201+
`sym$`a`b`b
202+
q)e,:`c
203+
'cast
204+
[0] e,:`c
205+
^
206+
207+
```
208+
209+
Conversely, if `x` contains unenumerated symbols, any enumerations are de-enumerated as part of the append:
210+
211+
```q
212+
q)s:`a`c
213+
q)s,:`sym$`b
214+
q)s
215+
`a`c`b
216+
```
217+
163218
----
164219

165220
:fontawesome-solid-book:

0 commit comments

Comments
 (0)