J vs BQN vs APL vs Jello

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ก.ค. 2024
  • Comparing the J, BQN, APL and Jello solutions to the Maximum Prime Differences problem.
    J Playground: jsoftware.github.io/j-playgro...
    J Primes: code.jsoftware.com/wiki/Vocab...
    BQNPAD: bqnpad.mechanize.systems/
    BQN Crate: mlochbaum.github.io/bqncrate/
    Dyalog APL: www.dyalog.com/
    Dyalog RIDE: github.com/Dyalog/ride
    Jello: github.com/codereport/jello
    Maximum Prime Difference: leetcode.com/problems/maximum...
    • The Superpower of C++
    • 1 Problem, 4 C++'s
    Chapters:
    0:00 Intro
    0:25 Brief Problem Description
    1:06 J Primes Function
    1:47 J Solution (Explicit)
    3:36 J Solution (Tacit)
    6:13 BQN Solution (Explicit)
    7:46 BQN Solution (Tacit)
    8:45 APL Solution (Explicit)
    10:09 APL Solution (Tacit)
    11:00 Jello Solution (Tacit)
    12:11 Array Language Comparison
    13:38 Outro
    Follow me on GitHub: github.com/codereport
    Follow me on Twitter: / code_report
    Follow me on LinkedIn: / codereport
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 28

  • @jacoblockwood4034
    @jacoblockwood4034 12 วันที่ผ่านมา

    The Jelly solution is great! I love how that `.` just so intuitively gives you that pipe-through function that is the B combinator. Beautiful!

  • @gentlemanbirdlake
    @gentlemanbirdlake 2 หลายเดือนก่อน +1

    I would like to see how to enact side effects from these terse array languages, more inline effects than just the implicit return at exit. Like in order to actually do something with all this efficient syntax as they run perhaps indefinately like a program loop and incorporating input from one or more streams of unknown termination.

  • @mzg147
    @mzg147 2 หลายเดือนก่อน +5

    No Uuia 😢

  • @CielMC
    @CielMC 2 หลายเดือนก่อน +5

    Could you please give some sources on learning these things? Like throughout the video I have no idea what tacit(Im guessing it's like point free where the argument is not explicitly mentioned?), 2-train, or the combinators are pretty blind to me. I have done some Haskell but the discover-ability seems horrible here

    • @code_report
      @code_report  2 หลายเดือนก่อน +6

      The paper and talk linked here are great starting points: combinatorylogic.com/

  • @arraycast
    @arraycast 2 หลายเดือนก่อน +5

    I would stay away from Caps ([:) in J and use Bind (&) to attach the 1 to p:
    ({:-{.) @ I. @ (1&p:) 4 2 9 4 3
    3

    • @arraycast
      @arraycast 2 หลายเดือนก่อน +5

      I just saw an even niftier approach on the APL farm:
      (1&p: (i: - i.) 1:) 4 2 9 4 3
      3

    • @c4tubo
      @c4tubo 2 หลายเดือนก่อน +2

      @@arraycast Team J returns the strong serve from Team anti-cap (Adám & Conor) 🏓

    • @rdatta
      @rdatta 2 หลายเดือนก่อน +2

      ​@@arraycast Readers may need to know that 1: is the constant function that returns 1. 1: x is 1 for all x. That allows turning the expression into a fork.

  • @ariaden
    @ariaden 2 หลายเดือนก่อน +8

    Another video that shows a list of languages that does not include Uiua? I thought we already established such videos are inherently flawed.
    Speaking of which, I have heard Uiua is no longer a fully functional language. Is there a simple problem that would show the Uiua solutions are no longer the most elegant?

    • @code_report
      @code_report  2 หลายเดือนก่อน +8

      Here is your Uiua solution: uiua.org/pad?src=0_11_0-dev_1__SXNQcmltZSDihpAgPTIvKz0w4pe_KzHih6EuCk1heFByaW1lRGlmZiDihpAgLeKKg-KKoijiiqLih4wp4oqa4oi1SXNQcmltZQoKTWF4UHJpbWVEaWZmIDRfMl80XzlfMwpNYXhQcmltZURpZmYgNF84XzJfOAo=
      IsPrime ← =2/+=0◿+1⇡.
      MaxPrimeDiff ← -⊃⊢(⊢⇌)⊚∵IsPrime

    • @dkebaili
      @dkebaili 2 หลายเดือนก่อน

      Not sure it's more elegant. There's no "last" and no "is_prime" so you'd need to do something like -∩⊢⟜⇌⊚∵(=1⧻°/×)

    • @TankorSmash
      @TankorSmash 2 หลายเดือนก่อน +2

      @@code_report I was looking forward to a Uiua section too, despite the video title. Thanks for linking this!

    • @marcosgrzesiak4518
      @marcosgrzesiak4518 2 หลายเดือนก่อน

      @@code_reportjust so you know, Uiuas ‘un’ is super helpful and makes finding primes much simpler:
      MaxPrimeDiff ← -∩⊢⟜⇌⊚≡(=1⧻°/×)
      In the front I just replaced the fork with an ‘on’ to save a few characters

    • @dkebaili
      @dkebaili 2 หลายเดือนก่อน +3

      IsPrime should probably be "equals 1 length un reduce multiply" since the opposite of a product reduction is an array of prime factors (!). Could even wrap it in "memo" so that checking the same number subsequent times is O(1).

  • @rubenverg
    @rubenverg 2 หลายเดือนก่อน +2

    I don't think there's currently an APL with both a Last and a Is Prime function; Extended Dyalog APL has 1⍭ for Is Prime, NARS2000 has 0π for Is Prime, and Dyalog APL Vision has ⊇ for last. Maybe Vision + the dfns library is close enough? I guess one of the things I might eventually add to TinyAPL is a pco-like primitive, so in tinyapl you might be able to write your solution as nice as possible, although you'll probably not like the lack of forks (I'll have operators to replace them, don't worry!)

  • @felipevaldes7679
    @felipevaldes7679 2 หลายเดือนก่อน +1

    Here is a summary of the video:
    The video solves the "Maximum Prime Differences" problem in four different array programming languages - J, bqn, Dyalog APL, and Jelly/Jellofish.
    The problem is: given a list of integers, find the distance between the first prime number and the last prime number in the list.
    It first shows how to solve it explicitly and tacitly in J, using J's built-in prime checking function and indices function. The tacit J solution requires using caps to avoid the S combinator.
    It then moves to bqn, which doesn't have a built-in prime checker, so it uses one from a library. The bqn tacit solution only requires one "cap" equivalent.
    For Dyalog APL, it uses the prime checker from the DEFUNDS library and the where function to find indices. The tacit solution uses function composition.
    Finally, for Jelly/Jellofish it uses the built-in is_prime and last functions. The tacit version is straightforward.
    The video compares the pros and cons of each language's solution, noting J and Jelly/Jellofish have nice last functions while bqn and APL require right reductions. It critiques J's need for caps/S combinator avoidance.

  • @casper5314
    @casper5314 2 หลายเดือนก่อน +7

    would these super compact languages be good for AI code generation? since you would need less tokens

    • @rothbardfreedom
      @rothbardfreedom 2 หลายเดือนก่อน +17

      Even C++ doesn't have so much text that modern AI can't process well. Also, more importantly, to find data/example for these languages is harder, thus the results will tend to be worse.

    • @douglasmennella4525
      @douglasmennella4525 2 หลายเดือนก่อน +6

      Also these languages tend to use overloading to be able to achieve this terseness which means there’s more context which I’d bet makes the learning harder.

    • @Dogo.R
      @Dogo.R 2 หลายเดือนก่อน +6

      Litteraly the opposite.
      The more tokens it takes the easier.
      See "Think in steps" and other examples.

  • @droid806
    @droid806 หลายเดือนก่อน

    Hi man! I'm back here from a couple of years away and I see you completed shift the channel. It's not about algorithms anymore but about these esoteric languages. Please go back to C++ and algorithms or "fork" the channel, a lot of ppl here is hostage to the previous content and don't think is fair.

    • @wargreymon2024
      @wargreymon2024 หลายเดือนก่อน +1

      please don't, C++ ugly 😭

  • @adenzu
    @adenzu 2 หลายเดือนก่อน +3

    j solution could also be
    (({:-{.)@:I.@(1&p:))

    • @jacoblockwood4034
      @jacoblockwood4034 12 วันที่ผ่านมา

      Isn't it nicer to use the [: instead of the second @ though? That way you don't need as many parentheses

    • @adenzu
      @adenzu 12 วันที่ผ่านมา

      @@jacoblockwood4034 oh thanks! didn't know that [: can be used in stead of @:

  • @trespaul
    @trespaul 2 หลายเดือนก่อน +4

    length . search . reverse . search
    where search = dropWhile (not isPrime)
    🤔

    • @trespaul
      @trespaul 2 หลายเดือนก่อน

      or something idk