Forum Replies Created

  • rolf

    Member
    November 15, 2023 at 12:00 am in reply to: Sort a Table
    q)t:([]sym:`a`b`c`d`e;x:til 5)
    q)t iasc`c`d?t`sym
    sym x
    -----
    c 2
    d 3
    a 0
    b 1
    e 4

    if you want to move the desired records to the top but want to preserve the order of the rest of the table

  • rolf

    Member
    October 3, 2022 at 12:00 am in reply to: Five easy pieces #2: getting around

    building on the above

    rnd:{(`up`dn`nr!(f ceiling;(f:{string(x z*s)%s:10 xexp y})floor;.Q.f'))[z][;y;x]}

     

  • rolf

    Member
    August 19, 2022 at 12:00 am in reply to: Swap key-value in dictionary
    {key[x][i]!get[x]i:iasc key x:group(!). flip raze key[x],''get x}

    indexing into the keys instead of doing a lookup a smidge faster

  • rolf

    Member
    July 3, 2022 at 12:00 am in reply to: Five easy pieces

    0: gets you the dashes in the date

  • rolf

    Member
    June 4, 2022 at 12:00 am in reply to: Five easy pieces #4: Little Six

    i think this is what you are after

    q)f:{abs(til[x]div 2)-x#(x-1),0} 
    
    q)f each 2*1+til 5 
    
    1 0 
    3 0 2 1 
    5 0 4 1 3 2 
    7 0 6 1 5 2 4 3 
    9 0 8 1 7 2 6 3 5 4

    i cannot claim authorship

  • rolf

    Member
    April 25, 2022 at 12:00 am in reply to: Generating unique symbol list does not consider symbols after `p

    p is the 16th letter of the alphabet.  not likely a coincidence.

  • rolf

    Member
    April 3, 2022 at 12:00 am in reply to: Five easy pieces
    q)f:"T"0:2 1#"dt"$ 
    q)f .z.p "2022-03-04T11:07:52.077" 
    
    / if you want to be picky about the type 
    q)f:first"T"0:2 1#"dt"$ 
    q)f .z.p "2022-03-04T11:08:49.988"