News for hackers. Stuff that matters.
Re: by leprechaun1066 on Wednesday July 09, 2025 @10:59AM (#44510821)
It's not because of the left of right evaluation. If the difference was that simple, most humans, let alone LLMs, wouldn't struggle with picking up q when they come from the common languages.

Usually when someone solves problems with q, they don't use the way one would for Python/Java/C/C++/C#/etc.

This is probably a poor example, if I asked someone to write a function to create an nxn identity matrix for a given number the non-q solution would probably involve some kind of nested loop that checks if i==j and assigns 1, otherwise assigns 0.

In q you'd still check equivalence, but instead of looping, you generate a list of numbers as long as the given dimension and then compare each item of the list to itself:

  {x=/:x:til x}3
An LLM that's been so heavily trained on an imperative style will likely struggle to solve similar (and often more complex) problems in a standard q manner.
Re: by wat10000 on Wednesday July 09, 2025 @11:13AM (#44511022)
A human can deal with right-to-left evaluation by moving the cursor around to write in that direction. An LLM can’t do that on its own. A human given an editor that can only append would struggle too.
Re: by anticensor on Wednesday July 09, 2025 @12:44PM (#44512149)
Idea: feed the language model the parse tree instead of the textual sequence.
Re: by wat10000 on Wednesday July 09, 2025 @03:13PM (#44513764)
Might help. You could also allow it to output edits instead of just a sequence. Probably have to train it on edits to make that work well, and the training data might be tricky to obtain.
Re: by gabiteodoru on Sunday July 13, 2025 @06:06PM (#44554200)
Yep, that's exactly what my MCP server is doing -- write in a Python-like language (I called in Qython), parse into AST tree, write the q code.
Re: by gabiteodoru on Wednesday July 09, 2025 @08:16PM (#44516009)
Or, even better, also from the cookbook: {(2#x)#1,x#0} But this really borders on obfuscation :P
Re: by leprechaun1066 on Sunday July 13, 2025 @02:40PM (#44552471)
That does require someone to know that the take operator continues to treat the y list as circular when x is a list.

I think this form might be a bit easier: {(x,x)#(x*x)#1,x#0}

Re: by gabiteodoru on Sunday July 13, 2025 @06:07PM (#44554213)
But then you're not flexing your q muscles. Btw this is from the cookbook, these obfuscated patterns are actually recommended! https://code.kx.com/phrases/matrix/#identity-matrix-of-order...