partitioned exercise question

https://learninghub.kx.com/forums/topic/partitioned-exercise-question

from the level 3 partitioned exercise: allPaths

given solution: allPaths:{[dir]sv'dir,'k where(k:key dir)like"[0-9]*"}

my functional solution: allPaths: {[dir] sv[; 'dir, 'k where (k: key dir) like "[0-9]*"]}

which returned stype evaluation error, due to the ' in front of dir.

It makes sense to remove the ' before dir and keep the one in front of k, given dir should only has one element and k can be a list ( and so the "each"). just wondering why is it in the solution that there is the ' between sv and dir, and that it works?

Thanks,

apologies for the formatting issue, no idea how to fix it...

Hi @lestat-jin

Apologies for the formatting issue on our side, we are working to fix this for future discussions.

Would you be able to send a screenshot of the code so we can help better assist you?

Thanks,

Megan

Sure, thanks.

Hi @lestat-jin

` sv'... is the dyadic form of each, x f'y: https://code.kx.com/q/ref/maps/#each
When ' is prefix -- not in an adverb position -- that's signal/throw: https://code.kx.com/q/ref/signal/

If you have any questions about this, feel free to reach out!

Thanks,

Megan

Thanks, so in the second version (functional form, ' in front of one func argument), this is read as signal? in general each should not be put in a function form?

Hi @lestat-jin

If we take a look at the format for the functional form of each (screenshot below) you can see the quote is used outside the square brackets.

So if I were to edit your answer it would look like:

allPaths:{[dir] sv'[`;dir, 'k where(k:key dir) like "[0-9]*"]}

I have removed the quote infront of dir and included it between sv and the square brackets as indicated in the documentation as this represents using each in functional form.

Let me know if this answers your question !

Thanks,

Megan

thanks, that is very helpful!