r/janetlang • u/Mental_Bumblebee7029 • 14d ago
pg_scalpel: a Janet interpreter in a live PostgreSQL backend
r/janetlang • u/xenow • Apr 15 '20
A place for members of r/janetlang to chat with each other
r/janetlang • u/Mental_Bumblebee7029 • 14d ago
r/janetlang • u/Veqq • Sep 19 '26
r/janetlang • u/Feisty_Bike_9614 • Jul 23 '26
Has anyone embedded Janet in rust ? I’m working on a prototype and would be interested in hearing your experience.
r/janetlang • u/Veqq • Jun 30 '26
I mostly talk to people in the zulip, but some different/outside voices could be useful. This way we can make progress on those things. :)
r/janetlang • u/torusJKL • Mar 23 '26
r/janetlang • u/abhin4v • Dec 13 '25
r/janetlang • u/abhin4v • Dec 05 '25
r/janetlang • u/Veqq • Jul 28 '25
r/janetlang • u/Veqq • Jul 12 '25
Clojure has assoc-in and CL's fset has with.
I implemented assoc-in:
(defn assoc-in [m ks v]
(if (empty? ks)
v
(let [k (first ks)
nested (or (get m k) @{})]
(put m k (assoc-in nested (slice ks 1) v)))))which can be used like:
(var t (table))
(assoc-in t [:a :b :c :d] "e")Then I learned put-in exists with the same semantics!
r/janetlang • u/IAmCesarMarinhoRJ • Feb 04 '25
A simple use to spork/rpc, a login microservice. In portuguese.
r/janetlang • u/breck • Jul 23 '24
r/janetlang • u/veydar_ • Dec 08 '23
AoC is still relaxed enough for me to look beyond my go-to language Lua.
I'm completely new to Janet and I'm trying to lean into its strengths and differentiating factors. Meaning I don't mind overengineering solutions. I also try to stick as close to 5 lines, 80 columns as possible without obfuscating code.
Anyway, here's day 1 mostly powered by PEG:
(def consts {"threeight" 38 "zerone" 01 "oneight" 18 "twone" 21 "fiveight" 58
"sevenine" 79 "eightwo" 82 "eighthree" 83 "nineight" 98 "zero" 0
"one" 1 "two" 2 "three" 3 "four" 4 "five" 5 "six" 6 "seven" 7
"eight" 8 "nine" 9})
(def longest-first (sorted (keys consts) (fn [a b] (> (length a) (length b)))))
(defn first-and-last [s] (-> (string (string/slice s 0 1) (string/slice s -2))
scan-number))
(def p1 (peg/compile ~(/ (% (some (+ (number :d) :a))) ,first-and-last)))
(def p2 (peg/compile ~(/ (% (some (+ (/ (<- (+ ,;longest-first)) ,consts)
(number :d) :a))) ,first-and-last)))
(def input (seq [line :in (file/lines stdin)] line))
(print (+ ;(map (fn [line] (0 (peg/match p1 line))) input)))
(print (+ ;(map (fn [line] (0 (peg/match p2 line))) input)))Let me know if there's room for improvement, especially with regards to making things even more concise.
r/janetlang • u/SCjdoh • Oct 15 '23
Pretty new to coding. Heard Janet does functional and imperative so may be easier to grasp in the beginning than Clojure. Planning to learn Clojure anyway but curious if Janet may make it easier. Thoughts?
r/janetlang • u/SCjdoh • Oct 13 '23
I want to try out Janet on Termux but when I try to build I get an error that the 'spawn.h' file doesn't exist. What can I do to fix this?
r/janetlang • u/jack-bloggs • May 05 '23
Hi, Just starting out with Janet and also using it as a teaching exercise and intro to lisp-likes for my ~13/14yo kids (and me actually).
We've just gone through translating some python code we wrote previously (sieve of Eratosthenes) to Janet, and I'd like thoughts on how Janet-idiomatic the new code is, what we could do differently, etc.
Also, the code has a big performance slowdown compared to python especially after the generator has run a while (say 100,000 primes), and I'd like advice on what kinds of things might speed it up. We did look into the source to look if there were any easy tweaks to the hash table (eg planning to add fibonacci hashing, but saw it was already being used). But a quick run with a profiler shows that most of the time is being spent in GC anyway.
Code:
(defn primes-sieve []
"
Prime numbers generator using sieve of Eratosthenes
Count upwards, building a 'sieve' of discovered primes, and discarding numbers that are
composites of primes already in the sieve.
Each entry in the sieve is a key pointing to a list of primes, where the key is
the 'next upcoming composite (multiple)' divisible by it's primes, eg { 45 @[3 5] }
For each number, check if it's one of the composites recorded in the sieve.
If it is, update the sieve with recalculated 'upcoming composite' entries for each prime
and delete the current entry.
If not, it must be a new prime; yield the number, and add an entry for it in the sieve.
"
(fiber/new (fn []
(yield 2) # the only even prime, yield it explicitly.
(let [sieve (table/new (math/pow 2 12))] # preallocating the sieve to ~= how many primes will be requested (at least) gives a big performance improvement
(loop [n :range [3 nil 2]] # only odd numbers
(if-let [current-composite (sieve n)]
(do
(each prime-factor current-composite
(let [next-composite-key (+ n (* 2 prime-factor))] # add 2*prime-factor, else composite would be even
(if-let [next-composite (sieve next-composite-key)]
(array/push next-composite prime-factor)
(put sieve next-composite-key @[prime-factor]))))
(put sieve n nil))
(do
(yield n)
(put sieve (* n n) @[n])) # next composite is n^2. Anything less is composite a smaller prime, already in the sieve
))))))r/janetlang • u/dressupgeekout • Dec 30 '21
r/janetlang • u/Ok-Philosopher-146 • Oct 08 '21
I'm trying to learn Janet by using janetui. I have a background in Clojure.
I am getting an error trying to build janetui. This is my project file:
(declare-project
:name "mylib" # required
:description "a library that does things" # some example metadata.
# Optional urls to git repositories that contain required artifacts.
:dependencies ["https://github.com/janet-lang/janetui.git"])and jpm -l deps gives me (a whole lot of output ending with):
error: target "CMakeLists.txt" does not exist and no rule exists to build it
in errorf [boot.janet] (tailcall) on line 165, column 3
in utd1 [/usr/lib/janet/jpm/rules.janet] on line 76, column 31
in visit [/usr/lib/janet/jpm/rules.janet] on line 85, column 12
in visit [/usr/lib/janet/jpm/rules.janet] on line 84, column 7
in visit [/usr/lib/janet/jpm/rules.janet] on line 84, column 7
in visit [/usr/lib/janet/jpm/rules.janet] on line 84, column 7
in build-rules [/usr/lib/janet/jpm/rules.janet] on line 93, column 19
in <anonymous> [/usr/lib/janet/jpm/pm.janet] on line 194, column 9
in <anonymous> [/usr/lib/janet/jpm/pm.janet] on line 181, column 5
in bundle-install [/usr/lib/janet/jpm/pm.janet] on line 179, column 3
in deps [/usr/lib/janet/jpm/commands.janet] (tailcall) on line 123, column 7
in _thunk [/usr/bin/jpm] (tailcall) on line -1, column -1
in cli-main [boot.janet] on line 3644, column 17I'm not sure what the error means. Do I need to create that file? Or should it exist in janetui (it already does: https://github.com/janet-lang/janetui/blob/master/CMakeLists.txt).
What fundamental thing am I missing here?
Thanks.
edit:
$ janet -v
1.18.0-dev-1bf22288
$ lsb_release -a
LSB Version: 1.4
Distributor ID: Arch
Description: Arch Linux
Release: rolling
Codename: n/a