Fork me on GitHub
#clojure
<
2024-01-17
>
Dallas Surewood01:01:30

Is GraalVM Polyglot the most legitimate option for running web assembly modules from Clojure? It seems like there's not a lot of JVM options

hiredman01:01:47

There are projects that convert wasm to jvm bytecode, I'd look at one of those

hiredman01:01:40

(or just use ffi and some native library for running wasm)

Dallas Surewood05:01:40

The only one I know of is asmble. Are there others?

hiredman06:01:30

https://github.com/wasmerio/wasmer-java maybe, it is a wrapper around the ffi approach

roklenarcic15:01:26

Is there a library with a sane string split function?

(str/split "" #"/")
=> [""]
(str/split "/" #"/")
=> []
(str/split "/a" #"/")
=> ["" "a"]
(str/split "/a/" #"/")
=> ["" "a"]

p-himik15:01:43

Try adding -1 as the last argument.

☝️ 3
thheller15:01:27

looks completely sane to me

roklenarcic15:01:11

In the last two examples there’s data loss, that’s not sane. I am not able to recreate back the starting string in the last case

thomas15:01:17

is it the same as the Java split?

roklenarcic15:01:34

Hm passing -1 seems to help

Noah Bogart15:01:43

Trailing empty strings are not returned - pass limit of -1 to return all.
is in the docstring

roklenarcic15:01:13

(str/split "" #"/" -1)
=> [""]
(str/split "/" #"/" -1)
=> ["" ""]
(str/split "/a" #"/" -1)
=> ["" "a"]
(str/split "/a/" #"/" -1)
=> ["" "a" ""]

roklenarcic15:01:32

worked with java for a long time and never noticed that “feature”

roklenarcic15:01:48

Thanks everyone

Noah Bogart15:01:59

i'd prefer it to default to all, tbh, but sadly that's not how it is

tomd15:01:54

also wrt "data loss" and "wanting to recreate back the starting string", zero-width lookaheads/behinds can help with that:

(str/split "/a/" #"(?=/)")
;; => ["/a" "/"]
(str/split "/a/" #"(?<=/)")
;; => ["/" "a/"]