APL vs BQN vs Uiua

Поділитися
Вставка
  • Опубліковано 31 гру 2024

КОМЕНТАРІ •

  • @red13emerald
    @red13emerald Рік тому +30

    The issue with your attempt of factoring out the function in Uiua is that the stack signature can't infer the signature of functions that are called from the stack (as those could be anything). So you have to explicitly specify how many inputs the function will take (number of outputs is 1 by default):
    StDev ← |1 √!⊙(|2 ⁿ2-!).(÷⊃⧻/+).
    Even if you didn't have to specify stack signatures though, the solution would still be longer and less readable than the original solution you came up with:
    StDev ← √÷⊃⧻/+ⁿ2-÷⊃⧻/+.
    StDev ← √!⊙(ⁿ2-!).(÷⊃⧻/+).
    I have to say, I absolutely love the clarity of this one:
    Avg ← ÷⊃⧻/+
    StDev ← √Avgⁿ2-Avg.
    So obvious, so easy to understand.

    • @c4tubo
      @c4tubo Рік тому +2

      I was banging my head to solve the signature issue, so thanks for that. And you also tightened it up by getting rid of the double-dipping. But I still prefer the fully tacit variation over naming the Avg function.

  • @whatthehelliswrongwithyou
    @whatthehelliswrongwithyou Рік тому +28

    we might simplify even further knowing that this is sqrt( - ^2)

  • @code_explorations
    @code_explorations Рік тому +26

    Love it. Please keep the Uiua content flowing 😊

  • @argonwheatbelly637
    @argonwheatbelly637 Рік тому

    Gentle rain, a hot pocket, and this video. Great morning! Thanks! The solutions are elegant and fun.

  • @charlieleemburg
    @charlieleemburg Рік тому +4

    Nice, tried it in my own language
    StDev ← ⋄ ⨱₁‒₁^2/+÷ₙ⫾√2
    Explanation
    ⋄ - this is not important just so it works in any context
    ⨱ - average
    ₁‒₁ - subtracting the average from the input
    ^2 - squaring
    /+ - sum
    ÷ₙ⫾ - dividing by the length of the input
    √2 - square root
    Though the combinators I find more elegant but they make my head spin, at least I don't have to repeat any code here.

  • @bailey6112
    @bailey6112 Рік тому +1

    I've loved seeing the Uiua content you've put out, it's given me a chance to practice the language as I watch

  • @rood2137
    @rood2137 Рік тому +13

    Uiua also has inverse and under combinator
    U ← ⍜⍘√(÷⊃⧻/+)-÷⊃⧻/+.
    Also, solution with annotated function signature
    F ← |1 √!∶ⁿ2-!⊙.,∶(÷⊃⧻/+)
    |x,y is a function signature, where x is number of arguments and y is a number of output values.
    In the F function we annotate that it takes 1 argument and omit num of out values

  • @r4fa3l59
    @r4fa3l59 Рік тому +8

    I came back from school just a while ago and was getting ready for dinner (it's 10:58 pm here in Brazil) and then I saw your notification... Gotta watch that first!

  • @davidzwitser
    @davidzwitser Рік тому +2

    Absolutely amazing. Especially the BQN one because that one I understood. Love these videos!

  • @Arbmosal
    @Arbmosal Рік тому +15

    Have you used these languages for something bigger than these types of code problems? I'd love to see how one would e.g. build todomvc with htmx or so. Especially excited about Uiua

    • @sardonyx001
      @sardonyx001 Рік тому +3

      Uiua is actually very powerful. It even comes with threads. The official website for Uiua is written in Uiua and built with trunk (It is good to note that Uiua itself is written in rust).

  • @versacebroccoli7238
    @versacebroccoli7238 Рік тому +1

    Thanks for linking the talks yoh mentioned!

  • @sinom
    @sinom Рік тому +3

    I honestly have no idea about APL but in general that standard deviation expression saving the average might be because in general you will often need the average when you also need the standard deviation so maybe the original paper reused it at some point later on and already saved it in there so it only gets calculated once?

  • @Hedshodd
    @Hedshodd Рік тому +6

    Just real quick: uiua has an under operator too 😉

  • @robertfrysch7985
    @robertfrysch7985 Рік тому +5

    my preferred Uiua version:
    Avg ← ÷⊃⧻/+
    Std ← ⍜(ⁿ2)Avg-Avg.
    There are also possibilities to avoid repeating the Avg, e.g.:
    Std ← √!∶ⁿ2-!∶,,∶(÷⊃⧻/+)
    but I would like to see a more elegant and shorter way to do this :)

    • @jacoblockwood4034
      @jacoblockwood4034 9 місяців тому +1

      Sadly your second way of doing removing Avg no longer works since first class functions were removed. Your first way is very nice though. You can remove a character by using unsqrt instead of pow2, because then you can remove the parentheses.

  • @parlor3115
    @parlor3115 Рік тому +1

    APL all the way for me. It's much less verbose and is significatly more express in terms of its type system. 100% recommend!

  • @red13emerald
    @red13emerald Рік тому +2

    And just like that, Uiua removed functions on the stack and the call operator in version 0.0.21, so half of the part about Uiua is obsolete again 😂

    • @jacoblockwood4034
      @jacoblockwood4034 9 місяців тому

      Well, functions on the stack was kinda confusing anyway. Also, you can replicate this behaviour with macros.

  • @kibels894
    @kibels894 Рік тому +7

    The original made it very clear what operation was being done. Code golf is fun though.

  • @Bliss467
    @Bliss467 Рік тому +1

    A little surprised average isn’t a backed in function/symbol in uiua

  • @alejandroulisessanchezgame6924

    Hi i want to implement an APL interpreter and i want to know if can do it without legal problems because some modern features like trains are in dialog apl.

  • @inserteunnombreapropiado9079

    I kind of didn't understand all you were saying. Is there some sort of introduction to this programming paradigm for someone used to OOP? And also, can you write something more useful than these one-liners?

  • @badmanjones179
    @badmanjones179 Рік тому +11

    a uiuaer, or as i like to say, "wee-wah-wer"

  • @DrewryPope
    @DrewryPope Рік тому +1

    i.. almost understood this.

  • @mendelovitch
    @mendelovitch Рік тому +53

    Write-only languages.

    • @bzboii
      @bzboii Рік тому +4

      as in purely functional lol

    • @aloussase
      @aloussase Рік тому +30

      Skill issue

    • @tytrdev
      @tytrdev Рік тому +7

      @@aloussase xD
      I wonder if they would say the same about Mandarin or Kanji?

    • @tytrdev
      @tytrdev Рік тому +7

      @xnick99 after a while I imagine the symbols become meaningful and clear function names. Dont get me wrong I can’t read this shit either, but I’m sure if we spent a few hundred hours working in a code base with these languages we would be fine.

    • @cheeseplated
      @cheeseplated Рік тому +2

      ​​@xnick99in uiua you do write most of the glyphs by writing out their names and the interpreter formats them on runtime, no idea if there's an option to disable the reformatting though

  • @charstringetje
    @charstringetje Рік тому +4

    Uiuauizzard

  • @AntoshaPushkin
    @AntoshaPushkin Рік тому +5

    These languages are pretty much write-only. It's cool that you can have a 1-line solution for a problem that takes 20-30 lines of python code, but who cares if nobody can understand it, fix it, change it etc?

    • @Denny_Zmeen
      @Denny_Zmeen Рік тому +1

      That's a competency problem. You might as well say the same of Chinese or Japanese.

    • @AntoshaPushkin
      @AntoshaPushkin Рік тому

      @@Denny_Zmeen no, if you write 1-line programs in any language, it will be unreadable. Though other languages don't encourage you to write one-line weird things with strange characters

  • @01110100011101110110
    @01110100011101110110 Рік тому +6

    I'm sorry, but this is black magic. Burn the witch!

  • @scramjet4610
    @scramjet4610 10 місяців тому +2

    C'mon, seriously, the code at 6:00 is horrible to read, not at all intuitive, just a gaggle of symbols; as such, what is the point of this language? It seems like all these cutesy, new "languages" are just trivial, semantic tweaks of each other, cluttering up the language scape. May as well just create functions to do this with C and just use C. A new language should be fundamentally different, like Lisp vs C, or evern Forth vs C. This stuff look like just semantic gymnastics. Where's the value?

    • @jacoblockwood4034
      @jacoblockwood4034 9 місяців тому +3

      If you learn how it works, this way is actually much easier to read than more mainstream languages. Also, APL came out in the 60's, I wouldn't call it new :P

  • @RusMermaid
    @RusMermaid Рік тому +1

    What's your discord? I'd love to join