This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-18
Channels
- # atom-editor (5)
- # babashka (15)
- # beginners (80)
- # calva (11)
- # cestmeetup (6)
- # chlorine-clover (15)
- # cider (22)
- # circleci (3)
- # clojure (57)
- # clojure-europe (19)
- # clojure-italy (1)
- # clojure-nl (4)
- # clojure-spec (1)
- # clojure-switzerland (1)
- # clojure-uk (88)
- # clojurescript (92)
- # code-reviews (1)
- # cursive (6)
- # data-science (5)
- # datascript (6)
- # datomic (12)
- # events (7)
- # figwheel-main (2)
- # fulcro (55)
- # graalvm (2)
- # helix (6)
- # juxt (6)
- # kaocha (11)
- # luminus (2)
- # off-topic (82)
- # pathom (27)
- # portal (1)
- # re-frame (3)
- # reitit (25)
- # remote-jobs (8)
- # sci (11)
- # shadow-cljs (29)
- # slack-help (2)
- # spacemacs (9)
- # specter (4)
- # sql (9)
- # tree-sitter (1)
- # uncomplicate (1)
- # xtdb (26)
This is rad, I want to try it out @sritchie09
I’m planning on putting up a version of Maria.cloud with this preloaded, and porting this Quil layer I built over so it can animate too in the browser. I’ll drop a link when that’s set!
Let me know if you’re interested in the textbook exercises- those are all possible immediately, and I’ve put a good amount of work into making those accessible too
Yeah I’m definitely interested in those!
My dad is a physics professor and he’s been wanting me to make replacements for his Java applets and flash simulations
Amazing! I’m trying to gather a little crew together here so I’d be happy to send you a note when I get the ability to animate
This repo has a system I built to do the exercises in the original scheme, using the SICM textbook
There are a lot of educational physics simulations that are no longer usable so I’m interested in this
Yes, the goal here is to generate interactive in browser simulations, that you can fiddle with and easily make by writing down a lagrangian
Here’s a first attempt at using that library to generate animations with Quil
It worked really well! But I wanted to be able to embed it in the browser and let folks fiddle with the code... which led me to the big CLJS conversion
If you send me your email I can let you know when I have something up that’s in a good shape for others to start banging on and writing simulations with
Also, I’d be really interested to see your wish list
Of what simulations and models should exist. My bigger goal here is to make it possible to write “executable textbooks”
Sure! I’ll dm my email
Is there a way I can grab items from a list, one at time - like generators/yield in js?
the common way to do that is wrap the code in a context that traverses (like map or reduce), but you can also do this with core.async or interop
though I don't know off hand what the raw interop looks like without the js syntax
if this isn't out of date, it looks like generators are intentionally not available in cljs https://observablehq.com/@shaunlebron/proposal-generators-and-async-functions-in-clojurescript so you'd need to write at least a stub of js
if I'm reading it correctly
quoting (likely from this very same channel)
await/async is just sugar over functions that return Promise. You can always use the Promise API on the result of async function. If you need to provide async function in your cljs public API, just return Promise. Generators are sugar for generating stateful Iterators and way to add some kind of laziness to JS. Cljs structures are lazy and implement Iterator for long time. Cljs is ahead in this.
iterator, or even just a lazy seq, sure
I think iterator might be the way to go. It specifically has next
- giving me the next value, as opposed to lazy seq which gives me the entire seq up to a point?
a lazy-seq is more idiomatic, but requires a rearrangement of the code, so that instead of a stateful object providing new values, a function inside a comprehension consumes those values
I think I understand. It's all about changing mindset from that for-loop mentality, to data isn't it
yes, precisely
but for every solution that stores a state and reuses it, there's another that reifies that state into position on a lazy-seq and runs inside a map or reduce
and I think it's provable that (given some sort of async driver) both can do what the other does
iterator might be most direct for your usage, but code that's reshaped to use laziness instead tends to be better clojure code
When doing JS interop, is there an idiomatic way to propagate down nested obejcts without null-checking? In ES, there is this ?
operator. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
Can someone please suggest a simple data visualisation library in Clojurescript. The use case is to plot simple graphs like simple line plots/bar chart with smoothing option.
can someone point me in the direction of an auto documentation tool or library that has support for clojure.spec
while this isn't exactly what you're talking about, you can generators work with core.async same as Promises
Just to have asked: Is it possible to get the contents of an edn-file into clojurescript? The file contains some generated lookup data that I need in my frontend code. Currently I copy the contents into a var in a cljs-file, but it would be nice to instead just consume the edn-file directly (e.g. using (:require [“lookup.edn” :as lookup])) as that would pick up any updates to it. Is this possible without e.g. an AJAX request or having the backend inject it into the HTML page, … Thinking about it I might as well just generate a cljs instead of edn, but I would still be interested in an EDN solution.
you could create a macro that does this at compile time which be similar to your require example:
(defedn lookup "lookup.edn")
in clj file:
(defmacro defedn [name fname]
`(def ~name (quote ~(read-string (slurp fname)))))
Hey all - does anyone have tips on how to get a list of all vars declared in a namespace, from cljs?
I'm looking to write a function or macro that can do the equivalent of the evil :refer :all
, just for a repl session
nice, trying
or is that not a thing in cljs
not a thing
super strange... I 'm seeing this error:
Invalid :refer, macro sicmutils.env/literal-function does not exist in file
<cljs repl>
the macros seem to be getting treated as functions
(ns sicmutils.examples.pendulum
(:refer-clojure :exclude [+ - * / zero? partial ref])
(:require [sicmutils.env :refer-macros [literal-function]]))
(sending code link)
https://github.com/littleredcomputer/sicmutils/blob/sritchie/convert_env/src/sicmutils/env.cljc#L59
all of these macros seem affected
oh, I might have an idea... I may have left a .clj
file around, doing the importing
nope, not that. has anyone seen this, where macros simply aren't seen?
well if you're in cljs, there are no macros right?
sorry, my bad, let me summarize - I've got sicmutils.env
, which declares three macros
(and I've done this in a few spots around the library)
@alexmiller it's a cljc file, so we should be good here
https://github.com/littleredcomputer/sicmutils/blob/sritchie/convert_env/src/sicmutils/env.cljc#L63
here's the env file with macros:
then, when I try to evaluate this new namespace form that pulls in that namespace and refers macros: https://github.com/littleredcomputer/sicmutils/blob/sritchie/convert_env/src/sicmutils/examples/pendulum.cljc#L23
I see
Unexpected error (ExceptionInfo) compiling at (REPL:1).
Invalid :refer, macro sicmutils.env/with-literal-functions does not exist in file <cljs repl>
(ns sicmutils.examples.pendulum
(:refer-clojure :exclude [+ - * / zero? partial ref])
(:require [sicmutils.env :as e :include-macros true])
(:require [sicmutils.function :as f :include-macros true]))
(f/with-literal-functions [x y z])
works great at the repl, referencing this macro
(e/with-literal-functions [x y z])
fails
meaning, it doesn't act as a macro, so I see
WARNING: Use of undeclared Var sicmutils.examples.pendulum/x at line 1 <cljs repl>
WARNING: Use of undeclared Var sicmutils.examples.pendulum/y at line 1 <cljs repl>
WARNING: Use of undeclared Var sicmutils.examples.pendulum/z at line 1 <cljs repl>
I'll try to slim the ns way down and get a small repro
but thought someone might be able to pattern match on that strange error /behavior
are there any errors at macro time? e.g. a parse or compiler error in your Clojure REPL
let me try adding that line
no errors that I can see
@lilactown the macros seem to be acting as functions
that return their form?
this looks like the output you get when using bootstrapped clojurescript
this is cider, with the node repl
okay! we may have a winner
boooom thanks all!