Infix Notation question

https://learninghub.kx.com/forums/topic/infix-notation-question

Hi,


I am working on level 2 of the KX academy and had a question for infix notation.


I am using keyword except to manipulate a string by removing all capital letters in it.

However when I use the except keyword in the following infix notation it doesn't work

For example:


s: ABSIBeifehisrBTE

s2: s except .Q.A each s


This doesn't seem to do anything however if I write it this way:


s2: except[;.Q.A] each s

this works perfect.


What am I doing wrong with the infix notation for it to not work. Apologies if this is a simple question, I am still new to using KX/Q :)


Thank you.


Hi @Jonathan

If you simply run:

q) s except .Q.A
"eifehisr"

This should work fine.

Hi @megan_mcp

Thanks for the reply.

My example was not a good one. I realized that I had a list of strings so something like

"wKDe arB33e on"

"Ia quSesGREATt!"


When I run my original line of: "s except .Q.A" I get a type error and when I tried to add a "each" to it, I got parse errors. I guess my question would be how do I iterate through a list of lists while applying a function using infix notation.

Maybe I'm understanding wrong, but if it's a list of strings:

q)list: “wKDe arB33e on”, “I a quSesGREATt!”
q)list except .Q.A, .Q.n //remove capitals and numbers
"we are on a quest!"

Or if you meant a list of lists:

q)list1: ("TpFcIc", "endkDg", "ZORkwh"), ("SjKvBM", "ioWzYM", "Ibuyjf")
q)list1 except .Q.A
"pccendkgkwhjviozbuyjf"

Apologies if I'm not understanding correctly. If you could provide a screenshot of an example, I would be happy to help.


Megan

@megan_mcp

I have attached a picture of the question and the error I'm getting.


Hi @Jonathan

Thank you for sending the example!

Reply from @rocuinneagain

Sample data:

q)list:("wKDe arB33e on";"I a quSesGREATt!")

q)list

"wKDe arB33e on"

"I a quSesGREATt!"

except cannot operate on lists of lists

q)list except .Q.A

'type

[0] list except .Q.A

You can project and use each

q)except[;.Q.A] each list

"we ar33e on"

" a quest!"

Or to use infix notation use each left \:

q)list except\: .Q.A

"we ar33e on"

" a quest!"


Thank you! That helps alot.