Fork me on GitHub

@deleted-user re: shelling out -- symlinks are also not going to be doable for windows via an lts jvm until jdk 17 iiuc. i think jdk 14 might get them, but that's not lts.


by "get them", i mean have them in a state that it might actually be possible to use them on windows. the api is there already (may be in 11 even?), but apparently there is some technical issue with them not working iiuc.


it would be nice to not have to shell out for things though because that makes the code more likely to be platform dependent...however, since windows seems to have gotten curl in some form (and tar?), perhaps it's possible to get the things being "shelled out to" to somehow be common across platforms (or at least mostly so).


@sogaiu @deleted-user I added babashka.curl because I either had to add clj-http-lite which can't do everything (like patch request it cannot do) or hato which bloats the binary and compile times. This is why I opted for the lighter solution babashka.curl which seems to be sufficient for most common scripting needs. If there are problems with the Windows curl version I'd be happy to support them via a platform-specific check.


fwiw, i have no current resistance to babashka.curl -- am happy to see how this goes!


@porkostomus i guess it's now bb -f forebb.clj and not bb -f 4bb.clj?


on my machine it's 4bb.clj

Bobbi Towers08:03:05

that's just the name of the namespace, since it can't start w/ a number


ah, i see -- i pulled now and see it has changed


 forebb.clj => 4bb.clj | 473


at any rate -- great stuff!


@porkostomus Might be worth mentioning in #beginners and #announcements


this will be nice on android too once bb is ported to termux 😉


I don't have any android devices in my home, but contributions welcome 😉

😅 4

@porkostomus Somehow for answer 8 it doesn't accept my input:

#{:a :b :c :d}


$ clojure 4bb.clj

#8: Sets

Sets are collections of unique values.

(= __ (set '(:a :a :b :c :c :c :c :d :d)))
(= __ (clojure.set/union #{:a :b :c} #{:b :c :d}))

#{:a :b :c :d}

Sorry, try again...

#8: Sets

Sets are collections of unique values.

(= __ (set '(:a :a :b :c :c :c :c :d :d)))
(= __ (clojure.set/union #{:a :b :c} #{:b :c :d}))

$ rlwrap bb 4bb.clj

#8: Sets

Sets are collections of unique values.

(= __ (set '(:a :a :b :c :c :c :c :d :d)))
(= __ (clojure.set/union #{:a :b :c} #{:b :c :d}))

#{:a :b :c :d}

NICE! Here's the next one:

#9: conj on sets

When operating on a set,
the conj function returns a new set with one or more keys "added".

(= #{1 2 3 4} (conj #{1 4 3} __))


Ah, it seems to be a slight difference between clojure and rlwrap bb maybe

Bobbi Towers10:03:21

wow interesting


it worked here, so may be it's a rlwrap thing as you say.


in clojure I'm getting this exception:

#{:a :b :c :d}
"replaced" ("(= #{:a :b :c :d} (set '(:a :a :b :c :c :c :c :d :d)))" "(= #{:a :b :c :d} (clojure.set/union #{:a :b :c} #{:b :c :d}))")
#error {
 :cause "clojure.set"
 [{:type clojure.lang.Compiler$CompilerException
   :message "Syntax error compiling at (/private/tmp/4bb/4bb.clj:1912:1)."
   :data #:clojure.error{:phase :compile-syntax-check, :line 1912, :column 1, :source "/private/tmp/4bb/4bb.clj"}
   :at [clojure.lang.Compiler analyzeSeq "" 7115]}
  {:type java.lang.ClassNotFoundException
   :message "clojure.set"
   :at [.URLClassLoader findClass "" 471]}]


Although this works:

$ clj
Clojure 1.10.1
user=> (eval (read-string "#{:a :b :c :d}"))
#{:c :b :d :a}


you probably need to require clojure.set


I'll make a PR 🙂

Bobbi Towers10:03:12

could it be bc the ns doesn't match the filename?


no, in clojure clojure.set isn't yet required by default, but it is in bb

Bobbi Towers10:03:17

oh I see, that makes sense


do you want to keep answers/prob_num in version control explicitly?

Bobbi Towers10:03:43

I actually just received the smallest PR possible... someone reset it back to 1.


I guess it make sense if people make a fork and want to remember where they were


but you could also write it to ~/.config/4bb/prob_num or something. either is fine with me

Bobbi Towers10:03:33

hmm, yeah that could work too. I don't really have a strong opinion either


The risk of keeping it under source control is that people make PRs where this number is set to something different again 😉


Anyway, let's wait for people to actually complain about it

Bobbi Towers11:03:54

I think I'll add actual options to reset progress, run a specific problem or a random one, then it would make more sense to "hide" it, like a cookie


Also works with clojure:

$ clojure tests.clj

Testing forebb_test

Ran 1 tests containing 42 assertions.
0 failures, 0 errors.

Bobbi Towers11:03:27

Wow, that's great! Thank you!


While doing so I discovered a bug in clj-kondo:

😮 4


$ docker run --rm -it borkdude/babashka:0.0.76-SNAPSHOT bb -e '(-> (curl/get "") (json/parse-string true) :url)'

👍 8