# Composition type (105h)

**URL:** https://forum.kx.com/t/composition-type-105h/6104
**Category:** Community Support
**Tags:** kdb-and-q
**Created:** [May 22, 2009, 3:43pm UTC](https://forum.kx.com/t/composition-type-105h/6104 "2009-05-22T15:43:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![abatalshikov](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@abatalshikov](https://forum.kx.com/u/abatalshikov)
#### Post date: [May 22, 2009, 3:43pm UTC](https://forum.kx.com/t/composition-type-105h/6104/1 "2009-05-22T15:43:00Z")

</div>

Hello!

I read “q idioms” (https://code.kx.com/trac/wiki/qidioms),?10.?Replicate at depth:

```
q)d:{[n;f] $[n;d[n-1;f]';f]}q)h:{d[x;y#,:]z}q)z:2 5#"abcdefghij"q)z"abcde""fghij"q)q:h[0;3;z]"abcde" "fghij""abcde" "fghij""abcde" "fghij"q)r:h[1;3;z]q)r"abcde" "abcde" "abcde""fghij" "fghij" "fghij"q)s:h[2;3;z]q)s"aaa" "bbb" "ccc" "ddd" "eee""fff" "ggg" "hhh" "iii" "jjj"

```

I have some questions related to this sample:

1). “Composition” type creating.

```
q) ?f1: {x#,:}

q) type f1 3

105h / composition!

```

In docimentation I found only one way to create composition – with (')  
(https://code.kx.com/trac/wiki/Reference/Apostrophe).  
In Q4M2 book nothing about composition type.  
Where can I read about this form creating composition?

2). Problem with direct using of console output:

```
q) f1 3

#[3],:

q) (f1 3) 4?/ ok.

4 4 4?

q) (#[3],:) 4 / nothing! Why?

q) type?(#[3],:) 4

101h / unary primitive?!

```

3). Dot syntax for aplly not work with composition?

```
q) f1 3

#[3],:

q) (f1 3) 4?/ ok.

4 4 4?

q)?f1 . 3 4?/ Why not work?

'rank

```

And last big question: where can I read about?working with types 100h-105h?

/ Alexander

---

<div class="post-metadata">

### Author: ![abatalshikov](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@abatalshikov](https://forum.kx.com/u/abatalshikov)
#### Post date: [July 8, 2009, 1:12pm UTC](https://forum.kx.com/t/composition-type-105h/6104/2 "2009-07-08T13:12:00Z")

</div>

Someone please reply to me.On 22 ???, 18:43, Alexandr Batalshikov \<abatalshi…\> wrote:\> Hello!\> I read “q idioms” ([https://code.kx.com/trac/wiki/qidioms](https://code.kx.com/trac/wiki/qidioms)), 10. Replicate at\> depth:\>\> q)d:{[n;f] $[n;d[n-1;f]‘;f]}\> q)h:{d[x;y#,:]z}\> q)z:2 5#“abcdefghij”\> q)z\> “abcde”\> “fghij”\> q)q:h[0;3;z]\> “abcde” “fghij”\> “abcde” “fghij”\> “abcde” “fghij”\> q)r:h[1;3;z]\> q)r\> “abcde” “abcde” “abcde”\> “fghij” “fghij” “fghij”\> q)s:h[2;3;z]\> q)s\> “aaa” “bbb” “ccc” “ddd” “eee”\> “fff” “ggg” “hhh” “iii” “jjj”\>\> I have some questions related to this sample:\> 1). “Composition” type creating.\>\> q) f1: {x#,:}\> q) type f1 3\> 105h / composition!\>\> In docimentation I found only one way to create composition – with (’)\> ([https://code.kx.com/trac/wiki/Reference/Apostrophe](https://code.kx.com/trac/wiki/Reference/Apostrophe)).\> In Q4M2 book nothing about composition type.\> Where can I read about this form creating composition?\>\> 2). Problem with direct using of console output:\>\> q) f1 3\> #[3],:\> q) (f1 3) 4 / ok.\> 4 4 4\> q) (#[3],:) 4 / nothing! Why?\> q) type (#[3],:) 4\> 101h / unary primitive?!\>\> 3). Dot syntax for aplly not work with composition?\>\> q) f1 3\> #[3],:\> q) (f1 3) 4 / ok.\> 4 4 4\> q) f1 . 3 4 / Why not work?\> 'rank\>\> And last big question: where can I read about working with types 100h-105h?\>\> / Alexander\</abatalshi…\>

---

<div class="post-metadata">

### Author: ![Aaron\_Davies](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@Aaron\_Davies](https://forum.kx.com/u/Aaron_Davies)
#### Post date: [July 8, 2009, 2:38pm UTC](https://forum.kx.com/t/composition-type-105h/6104/3 "2009-07-08T14:38:00Z")

</div>

\>\> 2). Problem with direct using of console output:  
\>\>  
\>\> q) f1 3  
\>\> #[3],:  
\>\> q) (f1 3) 4 / ok.  
\>\> 4 4 4  
\>\> q) (#[3],:) 4 / nothing! Why?  
\>\> q) type (#[3],:) 4  
\>\> 101h / unary primitive?!

2.4 and up has sometimes overly-helpful output

define this:

q).q.unshow:{-1@-3!x;}

then u can see

q)unshow(#[3],:)4  
::

:: is a unary primitive

why that works out to ::, i don’t know–something about precedence, i expect

\>\> q) f1 . 3 4 / Why not work?  
\>\> 'rank

f1 is monadic from q’s point of view (1=count(get f1)1), dot isn’t  
smart enough to apply one arg to the function and another to its  
return
