I ❤️ APL & BQN

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

КОМЕНТАРІ • 61

  • @hkp9257
    @hkp9257 Рік тому +43

    Coming home from salsa dancing where I try not to break my legs to a video of Conor where I try not to overload my brain. Perfekt evening :)

  • @JamesSully
    @JamesSully Рік тому +41

    I'm gonna have a crack at doing Advent of Code 2022 in BQN (starts in 4 hours)
    You should do it too so I can learn from your solutions!

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

    I love this! I do feel like APL instructions tend to map to lines in other languages, somewhat (though of course instructions can be combined onto lines in other languages too, e.g. you can do 2 + 3 * 4 in almost every language). APL instructions are one character, and not counting the parentheses (since those probably wouldn't be necessary, splitting it up onto lines) the solution given in the video has 11 characters. APL definitely looks much more concise-and it is, for sure-but if you mapped the APL instructions to Python words, and added back in the necessary variables, you'd have a Python solution. What I love about APL most isn't the fact that the solution is 13 characters; what I love is that there's no redundancy.

  • @boredstudent9468
    @boredstudent9468 Рік тому +78

    Just be obligatory reminder, that beeig verbose is not necessarily a bad thing. I much rather read in German than in Ithkuil. And i can mich easier comprehend what's happening in a Rust programm than Perl or even APL.

    • @arisweedler4703
      @arisweedler4703 Рік тому +36

      This is an APL fan account, sir, please take your correct opinions about scalable software elsewhere (jokes aside the obligatory reminder is received and respected)
      Terse code can be fun, and more truthful than verbose. Bad code is the real only enemy

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

      @@arisweedler4703 i know it is, and i kinda love it, thats why it's just the reminder not a rant essay. Sometimes i just need a little anger outlet.

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

      It's also nice to add that good code is always code that is maintainable, following clean code principles, when working in big companies, it's always good bein verbose when you gain simplicity with it, making other devs comfortable to maintain and improve your code.
      Just as a reminder that we don't write code for ourselves, but actually for other devs to be able to maintain and grow our codebase ☺️

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

      Reminds of another code_report video about a problem with two apl solutions, one slightly less "verbose" than the other, but also less performant.
      There's beauty and ungliness in both sides. Both ends can either make it easy on the eye and mind, but also they can obscure everything. Maybe, like in most things in life, the key is balance

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

      unless u go the other extreme .... toki pona

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

    Yess code report is back spreading the array gospel

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

    Superb! I've been listening to all of the ArrayCast podcasts and been hungering for more of these videos from you. It would be especially nice to get more stuff on BQN since you have convinced me that it is the best array language to use.

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

    code report upload??? what a pleasant surprise!!

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

    In BQN you can use the Cells 1-modifier instead of Rank 1.

  • @lucaayfmlyysiaejdsrtnnervd4646

    I don't understand a character that's there, but it's BEAUTIFUL!

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

    It will be great if you or someone provide separate tutorials on how to use BQN, J, and APL for very beginners. I would find more useful to learn how to install the programs and how to use each command (explained in a series of videos), and then some basic demonstrations/samples. That means: from zero to intermediate to advanced. The ones you are currently providing are advanced.

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

      I have a getting started video with APL: ua-cam.com/video/eACzuQGp3Vw/v-deo.html

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

      @@code_report Thank you, but that one is to install Dyalog on Ubuntu. It would be nice to have a tutorial specific to BQN that shows how to install it on Windows and the explanations on at least the most important commands. I did not find BQN tutorials on UA-cam that show the basics of BQN.

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

      @@code_report Thank you for the getting started video with APL, but that one is mainly about how to install Dyalog in Ubuntu and only a few commands. I have not found a UA-cam tutorial that shows the basics of BQN: How to install it in Windows, what editor is most recommended to type the commands, and an explanation of the commands specific to BQN. The same for J. Yes, I can visit websites related to those, but it will be nice to have UA-cam videos that actually show how.

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

    I have a hunch that aliens might read this code easier than us.

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

    While I have heard about APL, I still the title as a 'I love apple and bacon'.

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

      BQN is bad for you. Too much potassium nitrate and salt.

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

    Do you have recommendations on learning APL? I am on MacOS so it has to work on that platform.

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

    Negating the entire boolean array and then re-summing everything seems inefficient. You would get the same result by simply subtracting the row and column sums from their axis lengths. Incorporating that shortcut into the final outer product cleverly may in fact eliminate the need for outer product, I think. Also, in my opinion, the problem statement is needlessly obscure and difficult to follow. It’s like they’re trying too hard to not give away obvious candidate algorithms.

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

      Well, the whole expression should be optimised out into a single pass algorithm before execution so it's all good.

    • @0LoneTech
      @0LoneTech 4 місяці тому

      Something like this? +⌜´ ((2×+´)-≠)˘¨ ⋈⟜⍉ grid
      Take both the matrix and its transposition, subtract the axis length from twice the sum (since each 1 is a missing 0 also), and make a sum table from those two vectors.

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

    Bro really pulled out the standard galactic alphabet for this one

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

    This is all nice and everything, but a NumPy-based Python solution would be a two-liner and a **ton** more readable (and anyone doing serious matrix manipulation in Python would use NumPy anyway):
    y = 1 - x
    diff = np.add.outer(x.sum(axis=1) - y.sum(axis=1), x.sum(axis=0) - y.sum(axis=0))

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

    It's been 84 years...

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

    Code golf is the best golf

  • @585ghz
    @585ghz Рік тому

    😲 wowww Nice solution!!!

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

    If I don't know bqn or apl, and I learn bqn first, would there be any need to learn apl?
    Didn't bqn come from apl? Does apl offer something that bqn doesn't??

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

    Less is more.
    Flatter is better.
    Unicode thighs save lives.

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

    nice language and solution but the syntax uses goofy ahh symbols, which are nice in a way but hard to convey their meaning

  • @romaing.1510
    @romaing.1510 Рік тому +1

    Easily readable one liner numpy solution (as it is always possible):
    2 * (grid.sum(axis=0) + grid.sum(axis=1, keepdims=True)) - sum(grid.shape)

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

    Is BQN just a transliteration of APL, or of J for that matter?

    • @0LoneTech
      @0LoneTech 4 місяці тому

      No. There are differences in features like first class functions, role conversions, namespaces, affine characters, leading axis model, how to overlap shared glyphs, etc. But they probably share considerably more.

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

    My Julia code was "solution = sum(X, dims=1) .+ sum(X, dims=2) .- sum(X.==0, dims=1) .- sum(X.==0, dims=2)", but I'm not sure if I can reduce that any further.
    Weirdly I tested it with a 100x100 matrix and that version seems to scale better than the longer fully looped version (going from 6.5x slower with the 3x2 matrix to 74x faster).

    • @nunzioturtulici9636
      @nunzioturtulici9636 11 місяців тому

      I like Julia too
      [sum(v+w) for v ∈ eachrow(2X.-1), w ∈ eachcol(2X.-1)]
      (actually one should use a let to avoid computing twice 2X-1)

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

    how dare you offend the (actually surprisingly sizeable) hoards of bqn-invested children.

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

    beautiful, but not readable who cares!?

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

    For some reason the algorithm (™) chose not to present me this video but I’m very happy I found it now! code_report Leetcodes are back bb!

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

    If you want an extra challenge, try solving it in Prolog

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

      why, seems pretty straightforward?

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

      @@jayantchoudhary1495 I don't know if you actually have used it or not. But Prolog is so limited and imo difficult, it's probably one of the few languages where making a compiler and interpreter for it would be easier than actually learning how to properly use it. I might not have enough experience with Prolog to be a proper judge but for me at least it's difficult and frustrating even for trivial tasks.

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

      @@torarinvik4920 oh i have used it to solve may of the previous years advent of code problems. The problem usually is execution speed as I am still not good at optimization.
      For this particular problem just 1)take row wise and column wise sum (with accumulate)
      2)subtract n from it ( from the n by n grid provided) to get sum of zeros
      3) plug the formulas
      it's done.

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

      @@jayantchoudhary1495 Nice :)

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

    This works, too: -⍥(+/∘.++⌿)∘~⍨
    Basically, pass the argument to both tines of the fork, preprocessing the right side with negate.

  • @johnsmith-zr2br
    @johnsmith-zr2br Рік тому +3

    solution

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

    Where you have:
    x ← ...
    x
    this also works:
    ⊢x←...