Accessing the last element of List of List

https://learninghub.kx.com/forums/topic/accessing-the-last-element-of-list-of-list

x:(`Col1;12;.z.Z) y:(x;x;x) 
//add gtime of last element to end of x 
x,@[gtime;last x;0Np] 
//How do i do this for y?

So i think i did x correctly unless theres a better way. But how would i handle y? I want to append to end of each list in y.

This might be what you’re looking for then

q) x1:(`Col1;12;.z.Z) 
q) x2:(`Col1;12;`ERROR) 
q) show y:(x1;x1;x1;x2) 
`Col1 12 2021.12.08T17:46:26.162 
`Col1 12 2021.12.08T17:46:26.162 
`Col1 12 2021.12.08T17:46:26.162 
`Col1 12 `ERROR 
q) {x,@[gtime;last x;0Np]}each y 
`Col1 12 2021.12.08T17:46:26.162 2021.12.08T17:46:26.162 
`Col1 12 2021.12.08T17:46:26.162 2021.12.08T17:46:26.162 
`Col1 12 2021.12.08T17:46:26.162 2021.12.08T17:46:26.162 
`Col1 12 `ERROR 0Np

 

Hey @ekallivrousis - is this what you’re trying to do?

q)x:(`Col1;12;.z.Z)
q)y:(x;x;x)

`Col1 12 2021.12.08T17:33:36.400
`Col1 12 2021.12.08T17:33:36.400
`Col1 12 2021.12.08T17:33:36.400
q)y,'gtime .z.P

`Col1 12 2021.12.08T17:33:36.400 2021.12.08D17:33:47.617397000
`Col1 12 2021.12.08T17:33:36.400 2021.12.08D17:33:47.617397000
`Col1 12 2021.12.08T17:33:36.400 2021.12.08D17:33:47.617397000

Or are you looking to use the last item of each list of y (list of lists) as an input to gtime ?

Close, i want it to be in protected eval @, also i dont want to convert current .z.P i want to convert the last col of each list in y. I bold the column below that i want to use

Col1 12 <strong>2021.12.08T17:33:36.400</strong> Col1 12 2021.12.08T17:33:36.400
`Col1 12 2021.12.08T17:33:36.400