GithubHelp home page GithubHelp logo

bqn-libs's Issues

csv.bqn doesn't handle empty fields at the end of data correctly

Hi,
I found Split in csv.bqn converts "ab,,bc," to ⟨ "ab" ⟨⟩ "bc" ⟩ instead of ⟨ "ab" ⟨⟩ "bc" ⟨⟩ ⟩.
And it emits the following error by "ab,,bc,,":

Error: ⊔: ≠𝕨 must be either ≠𝕩 or one bigger (5≡≠𝕨, 3≡≠𝕩)
test/../csv.bqn:22:
    (0∾s/+`e<n) ⊔ (d(¬⊸×-⊣)+`s) ⊔ 𝕩
                ^
test/csv.bqn:19:
  ! ⟨⟨"ab",⟨⟩,"bc",⟨⟩,⟨⟩⟩⟩ ≡ c.Split "ab,,bc,,"
                               ^^^^^

So I came up with the following.

$ diff -u csv.bqn csv-rev.bqn
--- csv.bqn     2023-07-20 07:32:01
+++ csv-rev.bqn      2023-07-20 14:19:51
@@ -24,7 +19,7 @@
   e ← ≠`q       # Escaped characters
   s ← e<c∨n     # Split points
   d ← s∨q>»e<q  # Characters to be dropped
-  (0∾s/+`e<n) ⊔ (d(¬⊸×-⊣)+`s) ⊔ 𝕩
+  (0∾s/+`e<n) ⊔ (1++´s)↑(d(¬⊸×-⊣)+`s) ⊔ 𝕩
 }
                                                                                        
 # Parse list of lines, e.g. from •file.Lines

This seems to work well. But I don't know if it's the best solution... 😄

Unable to use Factor on certain numbers

I was trying to get an iterator of factorizations, and got an error for certain numbers. I was using CBQN, and ran

p ← •Import "primes.bqn"

•Out •Repr p.Factor 7718429
•Out •Repr p.Factor 255
•Out •Repr p.Factor 256
•Out •Repr p.Factor 258
•Out •Repr p.Factor 259

•Out •Repr p.Factor 257

When I tried to run it, I got

2081‿3709
3‿5‿17
2‿2‿2‿2‿2‿2‿2‿2
2‿3‿43
7‿37
Error: ´: No identity found
/home/alexdikelsky/euler/prob_451/primes.bqn:106:
    Pow ← Mul{𝔽´𝔽˜⍟(/2|⌊∘÷⟜2⍟(↕·⌈2⋆⁼⊢)𝕩)𝕨}
               ^
/home/alexdikelsky/euler/prob_451/primes.bqn:115:
    C ← { 𝕊a: s MR a Pow d }  # Is composite
                   ^
13: source unknown
12: source unknown
/home/alexdikelsky/euler/prob_451/primes.bqn:116:
    0 {𝕨<⟜≠◶⟨1,C∘⊑◶⟨+⟜1⊸𝕊,0⟩⟩𝕩} Witnesses 𝕩
        ^^^^^^^^^^^^^^^^^^^^^
/home/alexdikelsky/euler/prob_451/primes.bqn:116:
    0 {𝕨<⟜≠◶⟨1,C∘⊑◶⟨+⟜1⊸𝕊,0⟩⟩𝕩} Witnesses 𝕩
    ^
9: source unknown
8: source unknown
/home/alexdikelsky/euler/prob_451/primes.bqn:91:
    c◶⟨(ט¯1⊑p)⊸<◶1‿MillerRabin, 0⟩ 𝕩
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6: source unknown
5: source unknown
4: source unknown
/home/alexdikelsky/euler/prob_451/primes.bqn:159:
    2⊸⌊◶⟨!∘"Can't factor 0", 2‿0⊸⥊, IsPrime◶⟨FactorTrial, ≍˘≍⟜1⟩⟩ 𝕩
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2: source unknown
1: source unknown
factor.bqn:9:
  •Out •Repr p.Factor 257
               ^^^^^^

It looks like 257 doesn't work, but the numbers around it work fine. 257 is prime. Factoring the next prime (263) works fine.

Small primes not called prime by IsPrime

When I run

primes ← •Import "primes.bqn"
•Out¨ •Repr¨ (primes.IsPrime 2+(↕30)) ∾¨ 2+(↕30)

in CBQN, I get that 2, 3, 5, 7 are not primes. I'm using the most recent version of bqn-libs.

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.