beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
2021-01-27T06:44:15.416100Z

That's a good question, I think number to string conversion is actually implemented similar to your solution, so it's probably optimal

Marco Pas 2021-01-27T09:21:12.421600Z

I am trying to use a custom deps.edn in my ~/.clojure/ folder.

{
 :paths ["src"]
 :aliases
 {

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; Creating projects from templates

  ;; clj-new - <https://github.com/seancorfield/clj-new>
  :new {:extra-deps {seancorfield/clj-new {:mvn/version "1.1.234"}}
        :exec-fn clj-new/create
        :exec-args {:template "app"}}}
}
https://github.com/seancorfield/clj-new According to the documentation it states that i can use the alias to create a new project. But whenever i try to execute the command clojure -X:new :name myname/myapp i get an error message
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-X:new (No such file or directory)
When i make a typing error in the deps.edn it states the error, so i am sure the custom deps.edn is used. Any pointers what i am doing wrong?

GJ 2021-02-01T15:32:27.340700Z

This rings a bell... I followed the direction for the aliases and it didn't work.

GJ 2021-02-01T15:33:00.340900Z

(Checking my notes) The first command to use is clojure -A:new app practicalli/simple-api-server which doesn't work, because we have to install the clj-new project. This is done by updating ~/.clojure/deps.edn and adding an alias Note that copying and pasting the example from the readme doesn't work {:aliases {:new {:extra-deps {seancorfield/clj-new {:mvn/version "1.1.234"}} :exec-fn clj-new/create :exec-args {:template "app"}}} ...} But this does: :aliases { :deps {:extra-deps {org.clojure/tools.deps.alpha {:mvn/version "0.9.857"}}} :test {:extra-paths ["test"]} :new {:extra-deps {seancorfield/clj-new {:mvn/version "1.1.234"}} :exec-fn clj-new/create :exec-args {:template "app"}} } Sorting this out was interesting (something to do with the curly braces).

phronmophobic 2021-01-27T09:28:32.423Z

that same command and same deps alias works fine for me. the error makes it seem like there might be an extra argument being passed

phronmophobic 2021-01-27T09:29:28.423400Z

it looks like it's trying to open a file named "-X:new"

2021-01-27T09:31:14.423700Z

which version of clojure cli you using?

2021-01-27T09:32:24.425300Z

execution mode was added in https://clojure.org/releases/tools#v1.10.1.697

Marco Pas 2021-01-27T09:32:48.425900Z

Aaah so i am running an older version šŸ™‚

2021-01-27T09:33:02.426300Z

yes) update should fix that

Marco Pas 2021-01-27T09:33:14.426600Z

Thanks!!! Was searching all over the place šŸ™‚

Marco Pas 2021-01-27T09:33:17.426800Z

Thanks a lot!!

Marco Pas 2021-01-27T09:40:42.427500Z

@delaguardo It worked!!! Again thanks!

2021-01-27T09:40:53.427700Z

:thumbsup_all:

practicalli-john 2021-01-27T10:26:10.432100Z

@marco.pasopas you may find this book useful when using Clojure with CLI tools http://practicalli.github.io/clojure/ I also have a well documented user-wide deps.edn configuration with a wide range of tools https://github.com/practicalli/clojure-deps-edn

šŸ‘ 1
roelof 2021-01-27T10:27:59.433Z

so no free resources to learn re-frame or reagent

2021-01-27T10:30:01.433500Z

there are plenty documentation available for both )

roelof 2021-01-27T10:38:01.434600Z

also courses or tutorials where a site is build

roelof 2021-01-27T10:38:48.436Z

I have done one which works wih on-click but I see also some of them which uses subscribe so confusing

simongray 2021-01-27T10:38:53.436200Z

I recommend the guides on http://purelyfunctional.tv

simongray 2021-01-27T10:39:01.436500Z

they are excellent

roelof 2021-01-27T10:45:24.437600Z

Thanks, some study to do

practicalli-john 2021-01-27T10:46:37.438300Z

Any suggestions on getting started and designing apps with Clojure and Kafka streams? I've ask this in #apache-kafka so appreciate answers there. https://clojurians.slack.com/archives/CDAA5T4KZ/p1611742901000200

Marco Pas 2021-01-27T11:27:43.439200Z

@jr0cket Thanks for the pointer! I already found the deps.edn collection and surely they are usefull!!

šŸ‘ 1
Hagenek 2021-01-27T16:20:18.440900Z

An error has occured for me a couple of times the past days (Using Vs Code and Calva). Anyone know why this is happening?

Syntax error compiling at (src/clojure_functions/core.clj:22:1). Unable to resolve symbol: defn in this context

2021-01-27T16:27:06.441200Z

do you have :refer-clojure in your ns?

Hagenek 2021-01-27T16:27:25.441400Z

No I just have (ns clojure-functions.core), how should it look and why?

2021-01-27T16:29:18.441700Z

Iā€™m asking because it is possible to exclude symbols from clojure.core using form like that (:refer-clojure :exclude [defn]) in ns

2021-01-27T16:30:55.441900Z

do you mind to share the code? it is hard to guess based on exception message

Hagenek 2021-01-27T16:31:32.442100Z

Yeah I understand! Here is the full code:

(ns clojure-functions.core)


(defn my-reduce
  "expects a funtion a value and a collection"
  ([f coll]
   (if (empty? coll) (f)
       (my-reduce f (f (first coll) (second coll)) (rest (rest coll)))))
  ([f val coll]
   (loop [acc val remaining-coll coll]
     (if (empty? remaining-coll)
       acc
       (recur  (f acc (first remaining-coll)) (rest remaining-coll))))))

(defn my-count
  "returns the number of items in a collection"
  ([coll] (my-count coll 0))
  ([coll acc]
   (if (empty? coll)
     acc
     (my-count (rest coll) (inc acc)))))

Hagenek 2021-01-27T16:32:11.442300Z

It is working when I test the functions with Midje, so its related to the Calva I think

2021-01-27T16:33:19.442500Z

yeah, lgtm so probably it is midje or calva

Hagenek 2021-01-27T16:33:22.442700Z

Everything works again now

Hagenek 2021-01-27T16:33:38.442900Z

Without me changing any code, just pressed ctrl-alt-c + enter a couple of times

dpsutton 2021-01-27T16:33:46.443100Z

this can often happen if you execute (in-ns my-namespace) before requiring or executing a proper ns form

2021-01-27T16:35:25.443300Z

right! I can reproduce

dev&gt; (in-ns 'sample.core)
;; =&gt; #namespace[sample.core]
sample.core&gt; (defn foo [])
Syntax error compiling at (*cider-repl xapix/clojud:localhost:49518(clj)*:2721:14).
Unable to resolve symbol: defn in this context

Faris 2021-01-27T17:01:50.444200Z

Iā€™m getting this error when trying to jack-in using Cider

. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling src/reader/snake.clj at (1:41)

             Compiler.java: 7526  clojure.lang.Compiler/load
                      REPL:    1  user/eval6049
                      REPL:    1  user/eval6049
             Compiler.java: 7062  clojure.lang.Compiler/eval
             Compiler.java: 7025  clojure.lang.Compiler/eval
                  core.clj: 3206  clojure.core/eval
                  core.clj: 3202  clojure.core/eval
    interruptible_eval.clj:   82  nrepl.middleware.interruptible-eval/evaluate/fn/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj: 1965  clojure.core/with-bindings*
                  core.clj: 1965  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   82  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  243  clojure.main/repl/read-eval-print/fn
                  main.clj:  243  clojure.main/repl/read-eval-print
                  main.clj:  261  clojure.main/repl/fn
                  main.clj:  261  clojure.main/repl
                  main.clj:  177  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   79  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   56  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  145  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  202  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  201  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  748  java.lang.Thread/run

1. Caused by java.lang.Exception
   No namespace: examples.import-static

Faris 2021-01-27T17:02:18.444800Z

Iā€™m following an example for Programming Clojure This is the code so far

(ns reader.snake
  (:import (java.awt Color Dimension)
           (javax.swing JPanel JFrame Timer JOptionPane)
           (java.awt.event ActionListener KeyListener))
  (:refer examples.import-static :refer :all))
(import-static java.awt.event.KeyEvent VK_LEFT VK_RIGHT VK_UP VK_DOWN)

Faris 2021-01-27T17:02:41.445300Z

This is from the example file itself, so I havenā€™t actually changed anything.

dpsutton 2021-01-27T17:04:56.445600Z

got a link to where you got this from?

dpsutton 2021-01-27T17:05:44.446800Z

but the error seems straightforward : "No namespace: examples.import-static". relating to your (:refer examples.import-static :refer :all) (which seems quite strange to me

Faris 2021-01-27T17:06:33.446900Z

The file in question is at shcloj3-code/code/src/reader/snake.clj

Faris 2021-01-27T17:07:16.447200Z

ooh

Faris 2021-01-27T17:07:33.447900Z

I think maybe I need to load the whole repo then?

Faris 2021-01-27T17:07:40.448100Z

instead of just this file?

dpsutton 2021-01-27T17:08:26.448600Z

yes. the examples.import-static is a reference to shcloj3-code/code/src/examples/import_static.clj

Faris 2021-01-27T17:09:17.449Z

I see, thank you very much!

pez 2021-01-27T17:19:22.449100Z

With Calva the easiest way is to always start with loading the file, Calva avoids loading things automatically for you. I think that is the way it should be, but it does create a Ux problem for people that are new to the dynamic nature of a Clojure program in development. Iā€™ve tried to mitigate it some by having the https://calva.io/try-first/ article of the docs start with: > You should start with loading the file you are working with. Do this withĀ Load Current File and Dependencies,Ā `ctrl+alt+c enter`.

Hagenek 2021-01-27T18:10:02.451100Z

Thank you so much for the answer, loving Calva btw, made me change from Emacs & Cider:v:

2
ā¤ļø 1
mathpunk 2021-01-27T18:40:47.452500Z

I'm trying to figure out how I can run tests for a namespace from the command line

mathpunk 2021-01-27T18:41:34.452600Z

Here's something that didn't work:

(ns com.logicgate.helper.config)
...
(defn -main []
  (test/run-tests 'com.logicgate.helper.config))

mathpunk 2021-01-27T18:41:50.452800Z

:test-config     {:main-opts ["-m" "com.logicgate.helper.config"]}

mathpunk 2021-01-27T18:42:03.453Z

clojure -M:test-config

mathpunk 2021-01-27T18:43:28.453200Z

any thoughts on how i can do this? for context, i'm trying to run these tests in a docker container, since i bet i'm going to mess up configuring for that environment

dpsutton 2021-01-27T18:44:31.453900Z

Have you looked at the cognitect test runner?

mathpunk 2021-01-27T18:45:03.454100Z

reading now....

adam-james 2021-01-27T18:45:38.454300Z

should the cmd be clojure -A:test-config?

mathpunk 2021-01-27T18:45:39.454500Z

this is likely to sort me out, thank you!

mathpunk 2021-01-27T18:46:47.454700Z

i'm pretty fuzzy on M vs A vs X, adam-james.... what i had was copypasta from my "true" main functions that do work from other ns's

adam-james 2021-01-27T18:48:58.454900Z

From the code you posted, it looks as if :test-config is an alias. My understanding is that -M specifies a namespace in which a main function exists, but -A will run an Alias from a deps.edn file. I use aliases to launch dev or build depending on needs.

adam-james 2021-01-27T18:50:35.455500Z

apologies, it looks like i was mixing up -M with -m. please disregard, I don't think I'm helping after all šŸ˜•

Christian 2021-01-27T19:23:06.457700Z

I wonder why:

(mapĀ Integer/parseIntĀ ["2011"Ā "3"Ā "21"]) ;this doesn't work

(Integer/parseIntĀ "2011") ; but this is fine

alexmiller 2021-01-27T19:24:13.459100Z

Itā€™s a Java method, not a Clojure function

2021-01-27T19:24:14.459200Z

Integer/parseInt is a Java method, not a clojure function. To use it with map and so on, you need to wrap it in an anonymous function like #(Integer/parseInt %)

šŸ™Œ 1
caumond 2021-01-27T19:25:57.461300Z

@manutter51, I didnt know this limitation. I guess it is more general where else does it apply ?

2021-01-27T19:26:48.462800Z

@caumond on the vm / bytecode level, "methods" don't exist as real things, they are something an object knows how to do and only the objects are concrete

2021-01-27T19:27:22.463900Z

@caumond a clojure IFn is an object that only exists to carry a method (one which clojure calls if you put it in parens)

2021-01-27T19:28:10.464900Z

so, more concretely, you can't put something that isn't an Object on the stack, and IFn is an object, so you can put it on the stack, unlike a method

2021-01-27T19:28:30.465400Z

in order to pass something as an argument, it needs to end up on the stack

2021-01-27T19:29:35.467400Z

you can use method call interop syntax with IFn objects

user=&gt; (.invoke str nil)
""

caumond 2021-01-27T19:29:39.467700Z

Yes. Very clear. Thanks. Im definitly not sure ive ever read something like that in the books I read.

2021-01-27T19:30:53.469800Z

(there's the potentially misleading fact that reflection api offers "method handles", which are Objects that allow you to manipulate / use the methods on another Object, but we'd be badly off if we needed to reflect and use method handles everywhere)

Sophie 2021-01-27T19:33:13.471300Z

Hey Guys, I'm kind of stuck trying to get some data from a textfile. It already worked today but I destroyed it likely.

(map #(subs % (count prefix)(clojure.string/split-lines (slurp file-name))))
#object[clojure.core$map$fn__4781 0x5f20155b clojure.core$map$fn__4781@5f20155b]
After converting the data I'm trying to compare them with clojure.set/difference but this works neither.
(let [proef  (set/difference (set prae) (set post)) ]
             (println proef)
        ))
Any suggestions what's going wrong?

dpsutton 2021-01-27T19:34:11.472300Z

your map is only given a single argument here rather than two. i imagine you need to spit the split-lines form out of the subs form

2021-01-27T19:35:04.472900Z

single arg map arity strikes again

2021-01-27T19:36:06.474400Z

there are two distinct reifications of methods as objects java.lang.reflect.Method and java.lang.invoke.MethodHandle, reflect.Method is the older reflection api, MethodHandle is the new stuff built to work with (but possible to use independent of) invoke dynamic

Sophie 2021-01-27T19:38:33.476Z

šŸ˜‚ Ok this is the reason the first one worked earlier this day. First one solved.

Henri Schmidt 2021-01-27T19:39:21.476400Z

@3samgal your second piece of code has an extra paren

Henri Schmidt 2021-01-27T19:39:37.476600Z

On the 3rd line

dpsutton 2021-01-27T19:39:59.477100Z

in the history of clojure paper (and elsewhere i think) rich mentioned that if he started Clojure again today it would be based on transducers by default rather than laziness. i wonder what that would look like

2021-01-27T19:40:27.477700Z

yeah - I suggest taking some time to learn normal formatting / indentation conventions, they tend to make it easier to find and fix these sorts of bugs

dpsutton 2021-01-27T19:40:58.478200Z

indentation doesn't matter to the computer but properly indented code will make mistakes jump out at you

2021-01-27T19:42:24.478700Z

it's like traffic rules or human language - at first it doesn't help, but it makes working with others a lot easier, and in theory an isolated Galapagos of coders could invent their own conventions that are equally useful in their context

2021-01-27T19:43:22.479500Z

(I learned this lesson about math recently, upgrading from an ad-hoc rotation and mirroring of shapes to standard matrix transforms)

dpsutton 2021-01-27T19:43:48.479800Z

indenting your matrices?

Sophie 2021-01-27T19:45:38.480Z

What is the common way for this in clojure? ( ( ( ) ) ) Like this?

2021-01-27T19:45:42.480200Z

I mean much more generally than that - my ad-hoc rotation / flipping code did everything the matrix transform did, but by using the standard mathematical object (a transform matrix) I have a reference which makes finding bugs easier

Sophie 2021-01-27T19:47:03.480700Z

Thanks for the hint, but the parenthesis is part of the function ahead. Any other ideas?

2021-01-27T19:47:34.480800Z

@3samgal we don't leave dangling braces, and split lines for clarity - eg.

(map #(subs % (count prefix))
     (clojure.string/split-lines (slurp file-name)))

2021-01-27T19:48:09.481Z

notice that the args for map line up (since they are at the same abstraction level)

2021-01-27T19:49:32.481800Z

(let [proef (set/difference (set prae) (set post))]
   (println proef))
the println aligns under the let not the [binding block] - it doesn't belong as a child of the bindings, it belongs as a child of let

sova-soars-the-sora 2021-01-27T19:50:29.482900Z

It's gotta be a #{set} to use clojure.set/union, clojure.set/difference https://clojuredocs.org/clojure.set/union https://clojuredocs.org/clojure.set/difference I think you could do (into #{} (distinct -vals-) since a set must have unique values only

Sophie 2021-01-27T19:50:30.483Z

Ok thank you. In school we are learning C. There we usually use parenthesis the other way.

2021-01-27T19:50:55.483300Z

right, that's why I compare it to traffic rules (we drive on our side of the street, they drive on theirs)

Sophie 2021-01-27T19:51:27.483600Z

:rolling_on_the_floor_laughing: Nice

Sophie 2021-01-27T19:52:19.484400Z

I solved it. Thank you so much.

1
tws 2021-01-27T19:52:43.484500Z

set will take care of the dupes, no need for distinct

roelof 2021-01-27T20:38:33.485900Z

Am I right that subcribe is re-frame where on-click is reagent and on both something happens ?

2021-01-27T20:46:58.487300Z

the :on-click function of an html element is the function that gets called if you click it - this is a direct translation of an html feature subscribe is an abstraction over reagent r/atom r/atom is a data structure that will cause your page element to be re-rendered if the data you access changes

2021-01-27T20:48:10.487500Z

instead of specifying a change to the DOM in order to change what renders, you provide a function that uses application data (via r/atom or subscription), and then the framework promises to call your rendering code if the data you used changes

2021-01-27T20:48:50.487700Z

on-click is one popular way to trigger an app data change that would lead to a re-render, but there are a few steps in between

2021-01-27T20:50:01.487900Z

the "something" that happens is that your template function gets called again with new data

Mno 2021-01-27T20:50:17.488100Z

you can think of it as a way to get data, but also as a way of telling your app to reload ā€œthis specific part of the htmlā€ when the data changes. for example this one has both:

(defn home-page []
  (let [form-data @(re-frame/subscribe [::subs/form-data])]
    [main-layout
     [:div.card&gt;div.card-content
      [:div.field.has-addons
       [:label.label "What's your name?"]
       (form-input "text" :name form-data)
       [:button.button.is-info.is-light {:on-click #(re-frame/dispatch [::events/push-state :quizzes/index])} "Select Quiz"]]]]
    ))

Mno 2021-01-27T20:51:32.488300Z

so in this case if the form-data changes, this part of the dom gets reloaded, and if you click the button, it dispatches an event (in this cases changes the ā€œrouteā€

roelof 2021-01-27T20:57:23.488500Z

Thanks

sova-soars-the-sora 2021-01-27T20:57:29.488700Z

sweet

roelof 2021-01-27T20:57:47.488900Z

so on both I can use subscribe or on-click ?

2021-01-27T20:59:42.489200Z

:on-click is typically used to turn user actions into data changes

2021-01-27T20:59:52.489500Z

then subscribe is used to turn data changes into content changes

2021-01-27T21:00:30.489800Z

(other things can cause data changes too, eg. data coming back from an api, or just landing on a new route)

pez 2021-01-27T21:00:52.490Z

There is a lot of CIDER still there in Calva even after distilling. šŸ˜ƒ

šŸ˜‚ 1
Christian 2021-01-27T21:08:03.490900Z

It's not possible to destructure in the arguments, right? Example might explain better:

(defnĀ decomp-testĀ [[aĀ bĀ c]]
Ā Ā (+Ā aĀ bĀ c))

(decomp-testĀ [[1Ā 2Ā 3]])Ā ;Ā soĀ thisĀ canĀ beĀ 6?
here a simple apply would work, it's more of a thought experiment, because it's perfectly fine in prolog

Mno 2021-01-27T21:09:14.491400Z

that would work, but with one more set of []

Mno 2021-01-27T21:09:31.491900Z

so:

(defnĀ decomp-testĀ [[[aĀ bĀ c]]]
Ā Ā (+Ā aĀ bĀ c))

Christian 2021-01-27T21:09:43.492300Z

Nice.

Christian 2021-01-27T21:10:14.493500Z

why do I need the triple?

2021-01-27T21:10:18.493800Z

NB nested destructuring (or mix of map and sequential destructure) is usually better done in a let block

Mno 2021-01-27T21:10:51.495200Z

the first one is just the arguments that come in, the second one is the first vector, and the third one is the second vector

2021-01-27T21:10:51.495300Z

@christiaaan because you are passing a one element vector of vectors, so your destructure needs to match the shape

Christian 2021-01-27T21:11:16.496200Z

can I have named arguments?

2021-01-27T21:11:28.496800Z

destructure gives you named arguments

2021-01-27T21:11:48.497500Z

maybe I misunderstand that question

Christian 2021-01-27T21:12:11.498100Z

no, you are right. I was just stumbling over the [[[ thing, as it looks not that idiomatic

2021-01-27T21:12:44.498800Z

@christiaaan right, the part that is weird is that you'd define operations on single item vectors of vectors

Mno 2021-01-27T21:12:53.499200Z

well itā€™s not common you pass a vector in a vector

Mno 2021-01-27T21:13:23Z

especially when itā€™s a 3 item vector in a 1 item vector.

Mno 2021-01-27T21:13:37.000300Z

oddly specific

Mno 2021-01-27T21:13:57.000800Z

Lemme see if I can give a nice example with the repl

Christian 2021-01-27T21:14:27.001400Z

my function gets a sorted list, and I wanted to avoid apply, I guess apply is prettier

Mno 2021-01-27T21:18:18.002Z

Here you can run this and see all the stages of destructuring that you went through

(let [first [[1 2 3]]
      [second] first
      [[a b c]] first
      [a2 b2 c2] second]

  (prn (str "first=" first))
  (prn (str "second= " second))
  (prn (str "sum of a b c= " (+ a b c)))
  (prn (str "sum of a2 b2 c2= " (+ a2 b2 c2))))

Mno 2021-01-27T21:18:49.002400Z

also itā€™s an example of how to use let to test destructuring a bit easier

Christian 2021-01-27T21:19:29.002700Z

Thank you, that helps indeed

2021-01-27T21:20:02.003100Z

I would have had [a b c] second on that last binding line (same result)

Mno 2021-01-27T21:20:31.003400Z

thatā€™s a good idea

Christian 2021-01-27T21:25:44.004100Z

I think it's easier to understand with the let

(defn is-valid? 
  "Checks the three sides of a would be triangle."
  [a b c]
  (let [[shortest short longest] (sort [a b c])] 
    (and (&lt; 0 shortest)
         (&gt; (+ shortest short) longest))))

2021-01-27T21:26:39.004900Z

@christiaaan also consider (&lt; 0 shortest longest (+ shortest short))

Christian 2021-01-27T21:27:14.005300Z

Right! I had this thought but could not reconstruct it

Mno 2021-01-27T21:27:14.005400Z

thatā€™s amazing

Christian 2021-01-27T21:27:20.005700Z

Beautiful

2021-01-27T21:27:23.005900Z

I guess that needs to be &lt;= maybe...

roelof 2021-01-27T21:27:35.006100Z

hmm, on the reagent course I followed I never used subcribe and on the re-frame course of the same person ` subscribe is used

Christian 2021-01-27T21:27:38.006500Z

0 length edges are not okay for a triangle

roelof 2021-01-27T21:27:40.006600Z

still very confusing

2021-01-27T21:27:46.007Z

cool

2021-01-27T21:28:27.008Z

@christiaaan my mental model for &lt; is that it takes a series of numbers whose line graph rises like the top half of the symbol šŸ˜„

2021-01-27T21:28:40.008500Z

it's like a stonks emoji

šŸ“ˆ 1
šŸ˜„ 1
Christian 2021-01-27T21:28:52.008700Z

šŸ˜‚

Christian 2021-01-27T21:29:09.009300Z

at this point we shoud probably not make fun about wsb stonks

2021-01-27T21:30:09.010100Z

it appears that we have no :stonks: or :line_goes_up:, which is probably for the best

2021-01-27T21:31:02.010300Z

reagent doesn't have subscribe, it's something re-frame introduces

2021-01-27T21:31:33.011Z

in fact you could say that re-frame is reagent + subscribe (plus a few nice widget definitions you can use)

Christian 2021-01-27T21:31:38.011200Z

I remember why I ditched the idea. That would eliminate equilateral triangles

2021-01-27T21:32:18.011500Z

right, shortest and longest could be equal

2021-01-27T21:32:51.012100Z

of course you could have (&lt; 0 shortest (inc longest) (+ 1 shortest short)) but that's weird

roelof 2021-01-27T21:40:41.012500Z

oke

roelof 2021-01-27T21:41:50.012700Z

oke, maybe I stay then with reagant because the only thing I need is to show a modal when a user clicks on a painting

roelof 2021-01-27T21:42:22.012900Z

but then first convert some html template to a reagent template

2021-01-27T21:43:23.013100Z

yeah, the basic big picture of a reagent version is that the atom would have a key for the data the modal uses, and the click would fill in data under that key

roelof 2021-01-27T21:43:40.013300Z

because I do not need subscribe. I solved the problem with fetching from api wth pre-loading

2021-01-27T21:43:43.013500Z

then the template decides whether to output the markup for the modal, based on whether it sees the data

2021-01-27T21:44:17.013700Z

right - this example is probably small enough that re-frame doesn't become especially useful yet, and you can always add re-frame to a reagent project later

roelof 2021-01-27T21:44:56.013900Z

hmm, I thought with a click could first fetch he data from the apio because I cannot know which pianting a user wants to see some info

2021-01-27T21:46:37.014100Z

1. user click makes a fetch start 2. fetch completes, r/atom gets filled in with new data 3. reagent runs your template again with the new data

2021-01-27T21:47:20.014300Z

one advantage of re-frame is its subscriptions make that flow more explicit, but it's still probably more than you need for this case

2021-01-27T21:48:18.014500Z

just remember that most UI changes start with changing contents of an r/atom

roelof 2021-01-27T21:49:22.014700Z

oke

roelof 2021-01-27T21:49:35.014900Z

that is clear

roelof 2021-01-27T21:50:46.015100Z

and maybe later I could try re-frame to instead of the pre-loading that the user sees a empty painting whcih is switched to the real image as soon as the url is returned

roelof 2021-01-27T21:51:20.015300Z

for now time to sleep . Thanks for the lessons

roelof 2021-01-27T21:52:02.015500Z

but one change at the time

Malik Kennedy 2021-01-27T22:21:22.016100Z

šŸ“ˆ

šŸ“ˆ 1
Mno 2021-01-27T22:22:19.016300Z

Malik knows emojis šŸ’¹

Malik Kennedy 2021-01-27T22:27:08.016600Z

Couldnt let this go un-STONKS'd

šŸ“‰ 1
šŸ“ˆ 2
evocatus 2021-01-27T22:49:37.017900Z

Hi! I finally made fast binary exponentiation algorithm. Could you review it? https://github.com/reflechant/binary-pow/blob/main/src/binary_pow/core.clj

2021-01-27T22:52:24.018700Z

so powers isn't the powers of x, it's x, square x, square(square x) etc?

2021-01-27T22:53:05.019300Z

I don't know this algorithm off the top of my head, but with a name like powers I expected powers of x

2021-01-27T22:55:21.020400Z

ins)user=&gt; (take 10 (iterate #(*' % %) 2))
(2 4 16 256 65536 4294967296 18446744073709551616N 340282366920938463463374607431768211456N 115792089237316195423570985008687907853269984665640564039457584007913129639936N 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096N)
(ins)user=&gt; (take 10 (iterate #(* % 2) 2))
(2 4 8 16 32 64 128 256 512 1024)
ā€¢ - edit, that last step's a doozy

evocatus 2021-01-27T22:55:45.021Z

@noisesmith it depends on whether the power is even or odd

evocatus 2021-01-27T22:56:01.021500Z

I was using this description: https://cp-algorithms.com/algebra/binary-exp.html

evocatus 2021-01-27T22:56:53.022600Z

was trying to write a tail-recursive version and failed

2021-01-27T22:57:25.022900Z

oh, it is a sequence of squares, super surprising but I see