Fork me on GitHub
#babashka
<
2020-03-08
>
sogaiu03:03:37

@nate_clojurians 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.

sogaiu03:03:58

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.

sogaiu03:03:24

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).

Nate Sutton04:03:00

I mean it's pretty platform at that point

borkdude08:03:22

@sogaiu @nate_clojurians 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.

sogaiu08:03:40

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

sogaiu08:03:06

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

borkdude08:03:46

on my machine it's 4bb.clj

porkostomus08:03:05

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

sogaiu08:03:11

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

sogaiu08:03:31

Fast-forward
 forebb.clj => 4bb.clj | 473

sogaiu08:03:47

at any rate -- great stuff!

borkdude08:03:56

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

sogaiu08:03:02

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

borkdude08:03:47

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

😅 1
borkdude10:03:37

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

#{:a :b :c :d}

borkdude10:03:31

$ 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} __))

borkdude10:03:47

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

porkostomus10:03:21

wow interesting

sogaiu10:03:59

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

borkdude10:03:16

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"
 :via
 [{: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 "Compiler.java" 7115]}
  {:type java.lang.ClassNotFoundException
   :message "clojure.set"
   :at [.URLClassLoader findClass "URLClassLoader.java" 471]}]

borkdude10:03:32

Although this works:

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

borkdude10:03:46

you probably need to require clojure.set

borkdude10:03:11

I'll make a PR 🙂

porkostomus10:03:12

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

borkdude10:03:45

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

porkostomus10:03:17

oh I see, that makes sense

borkdude10:03:39

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

porkostomus10:03:43

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

borkdude10:03:37

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

borkdude10:03:57

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

porkostomus10:03:33

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

borkdude10:03:16

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

borkdude10:03:43

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

porkostomus11: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

borkdude11:03:34

Also works with clojure:

$ clojure tests.clj

Testing forebb_test

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

porkostomus11:03:27

Wow, that's great! Thank you!

borkdude11:03:25

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

😮 1
borkdude17:03:01

@james427

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

👍 2