KX Community

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

Home Forums KX Academy Fundamentals Capstone 2.2

  • Fundamentals Capstone 2.2

    Posted by jacob on November 7, 2023 at 12:00 am

    Hi everyone,

    I feel like I’m close to solving 2.2 but I can’t quite seem to get there. I’ve tried using various forms of if statements to determine how the string begins and therefore where in the string the ID is positioned, you can see what I’ve tried in the screenshots attached.

    Would love any help to get past this point, thank you.

    jacob replied 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • megan_mcp

    Administrator
    November 7, 2023 at 12:00 am

    Hi ,

    I think one thing that could be helpful is using conditional evaluation Cond | Reference | kdb+ and q documentation – Kdb+ and q documentation (kx.com)

    So you’ve got:

     

    extractBrokerId: {[exchangeMessage] parts: "-" vs exchangeMessage;

     

    Which is correct.

    If we take a look at our messages table we can see that if the exchange message begins with CME – the brokerId is going to be at the end.

    If it begins with ISE – the brokerId is going to be in the middle.

    So using the conditional, we can basically say if the exchange message is like “CME*” then use the last part else use the middle part.

    Let me know if this helps,

    Megan

     

  • jacob

    Member
    November 17, 2023 at 12:00 am

    Thanks Megan,

    I finished the function using parts and the conditional

Log in to reply.