KX Community

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

Home Forums kdb+ Fastest Fibonacci sequence generator Re: Fastest Fibonacci sequence generator

  • albin

    Member
    February 16, 2024 at 12:00 am

    Thank you for the suggestion  . That’s an elegant solution.

    I’m struggling to understand it though. Could you please help explain the following?

    q) reverse sums 1 2 3 6 3 1 / This makes sense. q) (reverse sums) 1 2 3 1 3 6 / Why did we lose the reverse? q) (reverse sums::) 1 2 3 6 3 1 / Why did this recover the reverse? q) q) sums + / Makes sense. q) reverse |: / Reverse is a combination of the max and assignment operators? q) reverse sums + / Reverse was lost. q) reverse sums:: |+ / Max operator combined with sums?

    I suspect the issue is I don’t understand the meaning of | and ::. I had thought | was just the max operator but maybe is also has other meanings? I know :: has at least these meanings:

    • Defining a view.
    • Assignment in-place.
    • Assignment to a global variable.
    • The generic null.
    • The identity function.
    • An elided index used to select everything.

    Does :: have yet another meaning here or does one of the above apply?