GithubHelp home page GithubHelp logo

Unexpected repl behaviour about bqn HOT 10 CLOSED

andrewnc avatar andrewnc commented on May 26, 2024
Unexpected repl behaviour

from bqn.

Comments (10)

mlochbaum avatar mlochbaum commented on May 26, 2024 1

Those would be 3β₯Š0 and 2βŠ‘"abcdef". See Indices for more discussion on Select (⊏) versus Pick (βŠ‘) though.

from bqn.

mlochbaum avatar mlochbaum commented on May 26, 2024 1

The non-array part of formatting was just casting to a string with ""+x (it has to be implemented in Javascript, since there isn't a way to find a scalar's type from BQN yet). I've improved it to detect primitives and infinities, and use Β― for a minus sign. For non-primitive functions and modifiers, it just prints the type, for example *1-modifier*. Since they're anonymous functions, deconstructing them to get better output would be difficult with the current VM. But at least there are no raw function printouts any more.

from bqn.

dzaima avatar dzaima commented on May 26, 2024

It's printing the source code of the function. The JS BQN compiler converts your code to JS code to be evaluated, and it seems there's nothing preventing that source code from just being printed. As a simpler example, try just !.

from bqn.

andrewnc avatar andrewnc commented on May 26, 2024

Ok, fascinating, is this a user error on my end?

from bqn.

dzaima avatar dzaima commented on May 26, 2024

There's no reason to not allow printing functions, whatever that ends up as being. It could of course be made to print something nicer, but that's probably of relatively low priority compared to other things about the language.

from bqn.

andrewnc avatar andrewnc commented on May 26, 2024

Oh! I see, I am trying to call the functions, is there something obvious I'm missing to initiate that call?

from bqn.

dzaima avatar dzaima commented on May 26, 2024

{π•©βŸ0} 3 is equivalent to 3⍟0, which is syntactically like 3⍣0 in APL - you aren't calling anything, you end up with a 2-modifier (dyadic operator in APL terms), derived to a function. Similarly for 2β—Ά"abcdef" - it's again just deriving a 2-modifier

from bqn.

andrewnc avatar andrewnc commented on May 26, 2024

That makes sense, I'm coming from J and am still getting the hang of things.

How do I repeat 3 "0"s and select the 2th item respectively?

from bqn.

dzaima avatar dzaima commented on May 26, 2024

As a quick test, anything circled is a 2-modifier (aka conjunction; βŒ½β‰ are exceptions and are functions similar to APL), and superscripts (˜¨˘⁼⌜´`) are 1-modifiers (adverbs); see this

from bqn.

andrewnc avatar andrewnc commented on May 26, 2024

Ok perfect! I got my simple example working

{𝕩‿𝕩 β₯Š 1∾ 𝕩β₯Š0} 3

Thank you both for the help.

from bqn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.