select: how to execute a function over a list of strings?

q)h2d:{16 sv "0123456789abcdef"?x} / hex 2 decimalq)t:([]a:000069f000006a5000006a80;s:ab,c)q)ta s----------000069f0 a00006a50 b00006a80 cq)select h2d each a from t'type [2] h2d:{16 sv "0123456789abcdef"?x} ^q)select h2d over a from t'type [6] h2d:{16 sv "0123456789abcdef"?x} ^

<span style="color: #080;" class="styled-by-prettify">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff}
span.s1 {font-variant-ligatures: no-common-ligatures}


I would like to convert the hexadecimal address to decimal and then determine the size of each symbol.


p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {font-variant-ligatures: no-common-ligatures}

h2d “000069f0”

27120


h2d “00006a50”

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {font-variant-ligatures: no-common-ligatures}

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {font-variant-ligatures: no-common-ligatures}

27216


select magicfunc a, s from t


a s

-------

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {font-variant-ligatures: no-common-ligatures}

96 a

27216 b


p
.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff}
span
.s1 {font-variant-ligatures: no-common-ligatures}

p
.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff}
span
.s1 {font-variant-ligatures: no-common-ligatures}

p
.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff}
span
.s1 {font-variant-ligatures: no-common-ligatures}

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff}
span.s1 {font-variant-ligatures: no-common-ligatures}

Your h2d function takes string as input. change your query to below:

q) select h2d each string a from t

Your function is operating on a string input but you are passing in symbols.

You can cast the symbols to a string in your qsql statement or you can change the function definition to handle this and operate on the sym vector. e.g.


q)t:(a:000069f000006a5000006a80;s:ab,c)

q)t

a s

----------

000069f0 a

00006a50 b

00006a80 c

q)h2d:{16 sv’“0123456789abcdef”?string}

q)select dec:h2d[a]from t

dec

-----

27120

27216

27264

q)

http://code.kx.com/wiki/Reference/QuestionSymbol

Thanks