Live data from Hacker News

Show HN: KatLang – Language for Calculations

katlang.org

31–40 of 46 posts

Re: Show HN: KatLang – Language for Calculations

#31
post #27

Earlier quoted context omitted.

Your OCaml function example looks like feature I call conditional parameters in KatLang (inspired from Erlang). In mathematics exists many different concepts which are called perfect. For example, perfect numbers. God called Lucifer a perfect. I provided a definition for symbols perfectness and tokens perfectness. You can call it unprofessional, but I did my best. I do not call my work perfect to make it more signifi…

> Your OCaml function example looks like feature I call conditional parameters in KatLang (inspired from Erlang). It does! Elixir (coming from Erlang) and Haskell have the same thing, both through pattern matching of a function to different definitions. OCaml (and most other languages using pattern matching) pattern match inside a single definition. > In mathematics exists many different concepts which are called per…

Probably picking the term "perfect" was not the best think I could do. Seems, that others actively fight against it. I still believe that the perfect syntax has both attributes: 1) it is the shortest 2) it is expressive - you can express any expression in it. Picking that name made my life much more difficult.

Re: Show HN: KatLang – Language for Calculations

#32
post #21

Earlier quoted context omitted.

Without trying to speak to why "katlang" does what it does, there are other languages that do this and I can speak to how useful it is when you already prefer functions of low arity: It repeatedly demonstrates a substantial improvement in bug/defect reduction and code. APL does this; a function like {ω×α+ω} and assigns omega to the right-argument, and alpha to the left-argument. They also have ωω for the right-side f…

I will do some research on APL and your mentioned 'commute operator', cannot comment on it now. But regarding languages: k/q the issues with them is that they use x, y and z as keywords for the parameters. x is always the first parameter, y - second, z - third. In KatLang parameter names are not predefined keywords, you can pick almost any parameter names you like.

> But regarding languages: k/q the issues with them is that they use x, y and z as keywords for the parameters. x is always the first parameter, y - second, z - third. In KatLang parameter names are not predefined keywords, you can pick almost any parameter names you like.

They aren't in q either: x can be redefined to whatever you like.

How does KatLang determine which argument is first? Is it merely the first free variable?

Re: Show HN: KatLang – Language for Calculations

#33
post #32

Earlier quoted context omitted.

I will do some research on APL and your mentioned 'commute operator', cannot comment on it now. But regarding languages: k/q the issues with them is that they use x, y and z as keywords for the parameters. x is always the first parameter, y - second, z - third. In KatLang parameter names are not predefined keywords, you can pick almost any parameter names you like.

> But regarding languages: k/q the issues with them is that they use x, y and z as keywords for the parameters. x is always the first parameter, y - second, z - third. In KatLang parameter names are not predefined keywords, you can pick almost any parameter names you like. They aren't in q either: x can be redefined to whatever you like. How does KatLang determine which argument is first? Is it merely the first free…

Yes, the first unknown identifier becomes the first parameter, next unknown identifier becomes next parameter and so on...

Re: Show HN: KatLang – Language for Calculations

#34
post #32

Earlier quoted context omitted.

I will do some research on APL and your mentioned 'commute operator', cannot comment on it now. But regarding languages: k/q the issues with them is that they use x, y and z as keywords for the parameters. x is always the first parameter, y - second, z - third. In KatLang parameter names are not predefined keywords, you can pick almost any parameter names you like.

> But regarding languages: k/q the issues with them is that they use x, y and z as keywords for the parameters. x is always the first parameter, y - second, z - third. In KatLang parameter names are not predefined keywords, you can pick almost any parameter names you like. They aren't in q either: x can be redefined to whatever you like. How does KatLang determine which argument is first? Is it merely the first free…

According to Q documentation, Q supports only 3 implicit parameters x, y, z: https://web.archive.org/web/20190213035913/http://code.kx.co...

Re: Show HN: KatLang – Language for Calculations

#35
post #32

Earlier quoted context omitted.

> But regarding languages: k/q the issues with them is that they use x, y and z as keywords for the parameters. x is always the first parameter, y - second, z - third. In KatLang parameter names are not predefined keywords, you can pick almost any parameter names you like. They aren't in q either: x can be redefined to whatever you like. How does KatLang determine which argument is first? Is it merely the first free…

Yes, the first unknown identifier becomes the first parameter, next unknown identifier becomes next parameter and so on...

More specifically: the first unknown identifier becomes the first parameter for the closest algorithm defined with {} brackets. Properties (also called named algorithms) are defined as {} context. And KatLang program also is defined as {} context. I call it Second order algorithm - algorithms can contain another algorithms. First order algorithm is something defined between commas or semicolons. But inside brackets () or {} you can define second order algorithm.

Re: Show HN: KatLang – Language for Calculations

#36
post #32

Earlier quoted context omitted.

> But regarding languages: k/q the issues with them is that they use x, y and z as keywords for the parameters. x is always the first parameter, y - second, z - third. In KatLang parameter names are not predefined keywords, you can pick almost any parameter names you like. They aren't in q either: x can be redefined to whatever you like. How does KatLang determine which argument is first? Is it merely the first free…

According to Q documentation, Q supports only 3 implicit parameters x, y, z: https://web.archive.org/web/20190213035913/http://code.kx.co...

They're just variables like any other; {[x;y;z] x+yz} is almost exactly the same as {x+yz}

Re: Show HN: KatLang – Language for Calculations

#37

Earlier quoted context omitted.

Yes, the first unknown identifier becomes the first parameter, next unknown identifier becomes next parameter and so on...

More specifically: the first unknown identifier becomes the first parameter for the closest algorithm defined with {} brackets. Properties (also called named algorithms) are defined as {} context. And KatLang program also is defined as {} context. I call it Second order algorithm - algorithms can contain another algorithms. First order algorithm is something defined between commas or semicolons. But inside brackets (…

You might like looking at how Dyalog handles higher-order functions; John Scholes really put this beautiful presentation together about using them as a depth-first search reusable function https://www.youtube.com/watch?v=DsZdfnlh_d0 and if you haven't seen it, you should!

Re: Show HN: KatLang – Language for Calculations

#38

Earlier quoted context omitted.

It creates the situation where these two functions appear to be identical but they are not: A = x * y + x A = y * x + x It is an interesting subject, and in general you would want to balance usability, people's expectations, and succinctness.

It is not the same. A1 = x * y + x A2 = y * x + x A1(1, 2), A2(1, 2) returns results 3, 4 If You want to change parameter order, You can use Grace~ operator like this: A1 = x~ * y + x it moves parameter x one position towards the end of the parameters list. Sorry, I do not know how to post code snippets in HN properly.

I think they meant:

    A1 = x * y + x
    A2 = y * x + y

Re: Show HN: KatLang – Language for Calculations

#39
post #36

Earlier quoted context omitted.

According to Q documentation, Q supports only 3 implicit parameters x, y, z: https://web.archive.org/web/20190213035913/http://code.kx.co...

They're just variables like any other; {[x;y;z] x+y z} is almost exactly the same as {x+y z}

Can you explain the difference little bit more, Maybe using Javascript pseudocode as comparable example? I want to understand how Q is different from KatLang. The problem with me is that I do not know where I can try Q code, therefore I rely only on the documentation fragments I can find.

Re: Show HN: KatLang – Language for Calculations

#40
post #38

Earlier quoted context omitted.

It is not the same. A1 = x * y + x A2 = y * x + x A1(1, 2), A2(1, 2) returns results 3, 4 If You want to change parameter order, You can use Grace~ operator like this: A1 = x~ * y + x it moves parameter x one position towards the end of the parameters list. Sorry, I do not know how to post code snippets in HN properly.

I think they meant: A1 = x * y + x A2 = y * x + y

A1 in Javascript pseudocode would be:

  function A1(x, y) {return x*y + x; }
But A2 would be:

  function A2(y, x) {return y*x + y; }
If you do not like the default order of implicit parameters, you can always use Grace~ operator to move x or y. Prefix form moves the parameter one position towards the beginning of the parameters list, postfix form moves one position towards the end of the parameters list:

  A1 = y~ * x + y
or

  A1 = y * ~x + y
or [Edit]

  A1 = y * x + y~
In the last example take into consideration, that without Grace~ operator y is the first parameter, so, you need to move it one position towards the end of the parameters list - therefore use postfix form of Grace~ operator.
Post reply on HN