Flip vs Enlist when mapping a dictionary

Hello Al,

if I’m recieving data of unknown legnth and I’m trying to fip to a table, do I need to check the length of the data before flipping?

ie

if data is length 1

this works, enlist (ab`c)!(1;2;3)

if data is greater than 1 than I need to use flip (…

Is there an easy to way to do this without specifically checking the length?

Thanks!

Hi,

You can check the type of the incoming data. A list will have negative type and an atom will have positive.

Include a simple if-else like this

$[0>type first x;enlist; else just flip]

Regards,

Jason

Hi,

Joining an empty list to each line of data will allow flip to always work:

q)flip ab`c!(),/:1 2 3

a b c


1 2 3

q)

q)flip ab`c!(),/:(1 1; 2 2; 3 3)

a b c


1 2 3

1 2 3

Marcus

Awesome, thanks