It'd be nice to have something cleaner than Common Lisp, and a much smaller image size. If it has decent performance too, I'm sold.
You should try again.
https://github.com/Olical/conjure
The LSP for it works reasonably well.
According to [1], "the 3SUM problem asks if a given set of n real numbers contains three elements that sum to zero."
It's not clear to me what problem the Janet code solves but it's clearly not that 3SUM problem.
On the example input of
@[2 4 1 3 8 7 -3 -1 12 -5 -8]
it outputs @[@[6 1 7] @[2 5 10] @[1 2 9] @[4 6 9] @[3 0 9] @[6 2 0]]
For what it's worth, here's some Common Lisp code that does solve the 3SUM problem in O(n^2). (defun 3sum (a)
(let ((h (make-hash-table))
(len (length a)))
(dotimes (i len)
(setf (gethash (aref a i) h) t))
(dotimes (i len)
(dotimes (j i)
(when (gethash (- (+ (aref a i) (aref a j))) h)
(return-from 3sum t))))))
(3sum #(2 4 1 3 8 7 -3 -1 12 -5 -8))
;; => t
[1] https://en.wikipedia.org/wiki/3SUM
bjoli•4h ago
Why should I switch from my scheme of choice (guile) to Janet?
veqq•4h ago
Fibers are very interesting, even used for error handling. I've not wrapped my head around PEGs yet.
ggm•3h ago
exe34•2h ago
worthless-trash•3h ago
bjoli•2h ago
I would also make strings immutable, maybe like Guile's cow-strings, maybe blobs-with-cursors.
Definitely just copy Guile's delimited continuations.
I think I would just ignore most of r7rs, since I don't think it improves things for the progrmmer.
girvo•1h ago
natrys•18m ago
[1] https://github.com/emacs-mirror/emacs/blob/master/lisp/progm...
worthless-trash•3h ago
Its binaries are quite small, could wrap and embed raylib and a few small c libraries with no hassle. This makes distribution much easier.
For my simple 2d game jaylib (raylib) code.
I believe those are pretty standard to have on most OSX machines, the situation is similar for my Linux system.The LLM's really can't deal with janet though, they seem to think its clojure and screw up a lot of things.
asQuirreL•2h ago
That being said, these days I use Clojure for both (I use babashka to run scripts: https://babashka.org/)
3036e4•1h ago
I like that it is a small language without dependencies. Have it installed everywhere, including in termux on my phone. Good for scripting.
Used to daydream about a native Clojure and Janet is close enough to that. Does not have everything, but the cost in size and dependencies is so much lower. It is simpler and easier and runs well even on a RPi Zero.
terminalbraid•1h ago
atemerev•1h ago
xigoi•20m ago