mlochbaum / bqn-libs Goto Github PK
View Code? Open in Web Editor NEWInformal collection of BQN utilities
License: BSD Zero Clause License
Informal collection of BQN utilities
License: BSD Zero Clause License
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... 😄
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.
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
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.