Welcome to the new home of the KX Community and KX Academy! Existing users are required to reset their passwords to log in

Forum Replies Created

  • roryk

    Member
    March 19, 2024 at 11:00 am in reply to: Challenge 2 – Work out the Angle

    You don’t need any of the midpoint calculation, the answer in radians is atan ab%bc

  • roryk

    Member
    March 19, 2024 at 11:00 am in reply to: Something for the weekend?

     

    {x where not(&’:)” “=x} / 23 chars and fast f[not(&’:)” “=] / as a projection

     

  • roryk

    Member
    February 15, 2024 at 12:00 am in reply to: Strange data type prevents table operation on what looks like a table

    How come ‘exec col1 from tab’ doesn’t collapse, but tab `col1 does?

  • roryk

    Member
    February 15, 2024 at 12:00 am in reply to: Strange data type prevents table operation on what looks like a table
    Dropping into k can be useful to see the representation.
    Tab is
    
    +`time`col1`col2!(times;(`col11`col12!1 3;`col11`col12!5 33);(`col11`col12!1 3;`col11`col12!5 33))

    What’s interesting is that

    exec col1 from tab

    then produces

    (`col11`col12!1 3;`col11`col12!5 33)

     

    But pasting this into the repl gives back a table,

    +`col11`col12!(1 5;3 33)

    So it seems like there’s some automatic table conversion that’s not happening in exec, that does happen in other cases. Interesting! Not much of an answer, but might help to find one.

  • roryk

    Member
    February 15, 2024 at 12:00 am in reply to: Strange data type prevents table operation on what looks like a table

    Interesting, thanks. So is tab `col1 semantically different to tab.col1? Unexpected (to me anyway)

  • roryk

    Member
    May 11, 2023 at 12:00 am in reply to: Advanced Capstone 1.3 clarification

    Hi Michaela,

    Thanks for explaining the behaviour, I managed to fix the function and now it passes. I was joining on more columns than required. I see why you don’t need to join on lapId, but does it not make sense to join on date/session? Any default values from another date or session don’t seem like they would be particularly meaningful to me. Or is it expected to do any filtering before using the function, and therefore it’s not an issue? This doesn’t matter for the capstone, it’s more out of curiosity and what might be expected in practice.

  • roryk

    Member
    April 15, 2023 at 12:00 am in reply to: Issues with Filling Missing Values in Dictionaries

    You can use fill, you just have to convert to symbols and back.

    string `na^`$d

    The provided solution is probably better though.

  • roryk

    Member
    February 19, 2023 at 12:00 am in reply to: {$["j";x in V]'[x;"_"]} / Case

    As the comment says, this is case, https://code.kx.com/q/ref/maps/#case

  • roryk

    Member
    December 7, 2021 at 12:00 am in reply to: Website with practice examples

    Something like advent of code might be more like what you’re looking for, it’s not language specific but the problems are fun and it’s good practice.

     

  • roryk

    Member
    November 26, 2021 at 12:00 am in reply to: Rounding in select statement

    I would define

    round:{(floor 0.5+y*i)%i:10 xexp x}

    and then you can do

    select time, sym, round[1]price from trade.

    As a bonus, this works with negative numbers too, round[-3; 12345.678] is 12000.

  • roryk

    Member
    November 20, 2021 at 12:00 am in reply to: How can I replicate "each til count subs"

    Each is an iterator/adverb – what that line does is applies pub to each item of ’til count subs’, not applying pub to ‘each til count subs’.

  • roryk

    Member
    June 9, 2024 at 7:24 pm in reply to: Fast file reading

    Hi Megan,
    Thanks for the information!
    It would be interesting to know the reason, but I don’t want to take up too much of a dev’s time for a random curiosity. If someone is free to look into it and would want to, then it would be interesting to know but no problem if not.

  • roryk

    Member
    June 6, 2024 at 5:59 am in reply to: Fast file reading

    Hi, the file doesn’t contain spaces, it’s just one word per line. So the results are the same. If mmap is faster, is there a reason read0 doesn’t use it, or is it just a potential optimisation that hasn’t been implemented?

    It doesn’t really matter as only a couple of milliseconds for even a fairly large file, but it would be nice to have a deeper understanding of the performance of various operations.