Fork me on GitHub
#graalvm
<
2021-06-09
>
phronmophobic19:06:30

Just published a minimal example of compiling clojure code into a shared library targeting ios. https://github.com/phronmophobic/mobiletest

😎 4
phronmophobic19:06:47

It's not super useful on its own, but I'd like to experiment to see how viable it would be to build an iOS app with clojure+native-image

phronmophobic04:06:05

btw, I can confirm that sci runs natively on iOS 😄

borkdude09:06:59

@smith.adriane I wonder if it can be useful to hook up babashka.nrepl (which is a SCI-compatible nrepl server as a library) to this so you can then control your phone from a distance. Not sure if you can just open a server socket like that on an iphone

clojure-spin 2
phronmophobic17:06:23

;; Connected to nREPL server - 
;; CIDER 1.1.0snapshot (package: 20210104.915)
: Could not resolve symbol: clojure.main/repl-requires user *cider-repl var/tmp:192.168.0.48:23456(clj)*:1:42
nil> (ns foo)
nil
foo> 
foo> (+ 1 2)
3
foo> (defn neighbours [[x y]]
  (for [dx [-1 0 1] dy (if (zero? dx) [-1 1] [-1 0 1])] 
    [(+ dx x) (+ dy y)]))
#<SciVar@4debf57b: 
  #object[sci.impl.fns$fun$arity_1__4162 0x75ad55f0 "sci.impl.fns$fun$arity_1__4162@75ad55f0"]>
foo> (defn step [cells]
  (set (for [[loc n] (frequencies (mapcat neighbours cells))
             :when (or (= n 3) (and (= n 2) (cells loc)))]
         loc)))
#<SciVar@413be9d6: 
  #object[sci.impl.fns$fun$arity_1__4162 0x24fac9c7 "sci.impl.fns$fun$arity_1__4162@24fac9c7"]>
foo> (def board #{[1 0] [1 1] [1 2]})
#<SciVar@bfa3b74: #{[1 0] [1 1] [1 2]}>
foo> (take 5 (iterate step board))
(#{[1 0] [1 1] [1 2]}
 #{[1 1] [2 1] [0 1]}
 #{[1 0] [1 1] [1 2]}
 #{[1 1] [2 1] [0 1]}
 #{[1 0] [1 1] [1 2]})
😮 ^^ sci nrepl running on my iPhone