79571542

Date: 2025-04-13 12:41:22
Score: 0.5
Natty:
Report link
isSorted: {[xs]
    isSortedInner:{[xs;i;len]
        $[i>=len;1; (
            $[xs[i]<xs[i-1];
              0;
              .z.s[xs;i+1;len]
             ]
            )]
    };

    len: count xs;
    isSortedInner[xs;1;len]
};

This is recursive port of the python logic. Took me over an hour because I don't know KDB.

I doubt this is idiomatic or the fastest way of doing it. I don't even know if it's space efficient because of the recursion.

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Rol