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
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), 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</abatalshi…>
>> 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