KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums KX Academy Infix Notation question

  • Infix Notation question

    Posted by Jonathan on August 22, 2024 at 12:41 pm

    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.

    Jonathan replied 1 month, 2 weeks ago 2 Members · 6 Replies
  • 6 Replies
  • megan_mcp

    Administrator
    August 22, 2024 at 1:22 pm

    Hi @Jonathan

    If you simply run:

    q) s except .Q.A
    "eifehisr"

    This should work fine.

    • Jonathan

      Member
      August 22, 2024 at 1:39 pm

      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.

      • megan_mcp

        Administrator
        August 22, 2024 at 1:56 pm

        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

Log in to reply.