This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-10
Channels
- # aleph (1)
- # aws-lambda (1)
- # beginners (80)
- # boot (20)
- # cider (75)
- # cljs-dev (45)
- # cljsjs (1)
- # cljsrn (11)
- # clojure (428)
- # clojure-dusseldorf (13)
- # clojure-italy (4)
- # clojure-russia (153)
- # clojure-spec (47)
- # clojure-taiwan (1)
- # clojure-uk (62)
- # clojurescript (84)
- # cursive (19)
- # datascript (96)
- # datomic (75)
- # dirac (9)
- # docs (3)
- # emacs (19)
- # jobs (5)
- # jobs-discuss (20)
- # jobs-rus (17)
- # lein-figwheel (5)
- # leiningen (1)
- # liberator (4)
- # luminus (12)
- # off-topic (4)
- # om (31)
- # onyx (102)
- # pamela (1)
- # parinfer (3)
- # pedestal (3)
- # proton (1)
- # protorepl (14)
- # re-frame (54)
- # reagent (22)
- # rum (40)
- # spacemacs (2)
- # specter (8)
- # test-check (5)
- # unrepl (110)
- # untangled (80)
- # vim (3)
- # yada (46)
@adamkowalski It might be enough to implement the few interfaces mentioned here: https://clojure.org/reference/data_structures Until a better, more accurate advice comes along, you can study some of Zach Tellman's implementations: https://github.com/ztellman/clj-radix/blob/master/src/clj_radix.clj https://github.com/ztellman/clj-tuple/blob/master/src/clojure/lang/PersistentUnrolledMap.java Or this example: https://gist.github.com/david-mcneil/1684980
CompilerException java.lang.Exception: namespace 'picture-gallery.routes.auth' not found, compiling:(cider-repl picture-gallery:51:7)
@lepistane when does this happen? If you try to eval buffer in Emacs?
well i am reading book WebDev with Clj 2nd edition and i am at chapter 8 making picture-gallery we are supposed to make authentication so i made new file auth.clj in routes folder and tried to test register user function i made but i cant it get that error i used cider-browser-ns and i cant see routes.auth namespace why is that?
to double check you can always lein run
, lein test
, or lein repl
to make sure that there are no errors
hm, that's strange. Are you sure that you created the namespace in a proper directory?
I'm just looking at picture-gallery-a
from book's code examples and the namespace is "picture-gallery.routes.services.auth" (with "service") but it really doesn't matter much
just to make it clear:
- in the book the file structure is as follows: src/clj/picture-gallery/routes/services/auth.clj
-> you should declare namespace picture-gallery.routes.services.auth
in this case
- if you created file src/clj/picture-gallery/routes/auth.clj
then you should declare namespace picture-gallery.routes.auth
and be able to use it
error in process filter wrong type argument characterp nil getting this error while evaluating NS
@urbanslug not sure about elegance but something like take (let [s "1245"] (apply str (first s) (second s) ":" (rest s))) might work i am sure there are bugs or things u have to fix but that's my idea
@lepistane Yeah not too elegant (clojure.string/replace "1234" #"..$" #(str %1))
I have this which is close
@lepistane LOL phantom js says "undefined is not a constructor" even thought I've used the function just above this use. 🙂 will try your way. clj to cljs fails
@urbanslug No need to use replace when substing is enough.
Yes, substring. Typo.
i made it work!! how? well bottom up approach function was making error so it couldnt load NS tnx for help everyone
(macro-expand-1 '(defn-with-defaults foobar {:inc 1} [deps b] (+ (:inc deps) b))
-->
(defn foobar
([b] (foobar {:inc 1} b))
([deps b] (let [deps (merge {:inc 1} deps)] (+ (:inc deps) b))))
I'm new to writing macros, but I think I'd need a macro that captures a variable on purpose (so it can add that overwriting let
expression), but I also need splicing-unquote, which I think is only available when syntax quoting
(defmacro defn-with-defaults
[name defaults params & body]
`(defn ~name
(~(vec (rest params)) (~name ~defaults ~@(rest params)))
(~params (let [deps (merge ~defaults ~(first params))]
~@body))))
~‘deps
should work, but I don’t think it is a good idea to write macros with magic variables like this
(defn-with-defaults increase {:inc 1} [deps a] (+ (:inc deps) a))
=> #'clojure.core/increase
(increase 1)
=> 2
(increase {:inc 5} 1)
=> 6
Nevermind the clojure.core
namespace, I accidentally switched to that namespace instead of my own core ns when trying this out in the REPL 😄
But that is what I want. Just imagine the function actually does something sensible, and gets for example a db connection in the deps parameter
I don't think gensym
helps me here, because the way I understand this is I need to have that let
block in the function body
here’s the problem:
kleinheit.extractor=> (macroexpand-1 '(defn-with-defaults foobar {:inc 1} [something b] (+ (:inc something) b)))
(clojure.core/defn foobar ([b] (foobar {:inc 1} b)) ([something b] (clojure.core/let [deps (clojure.core/merge {:inc 1} something)] (+ (:inc something) b))))
Yeah, I actually realised that. I'd be fine with it. Do you have any ideas how to avoid that though?
(I deleted some messages). I guess it would be better if the let-binding bound to the same symbol as the first parameter
quick repl question!. why can't i see the gen
namespace in this scenario? if i lein repl
then (use 'ms.specs)
and then try to call gen
i get Unable to resolve symbol: gen in this context
:
(ns ms.specs
(:require [clojure.spec :as s]
[clojure.spec.gen :as gen]))
I guess I can access the :as
definition like from a map.. and make the macro fail if there is none? I dunno
I don't seem to be doing this right. Does anyone know how to invoke the playbackRate method?
#?(:cljs (.playbackRate (. js/document (getElementById "my-video")) 0.6))
I am using Rum
If I get the component how to do the function on it
Don't know off the top of my head. That looks pretty close. You probably need to use a built-in function in Rum to access the React component, then call .playbackRate
on it 🙂
I'm sure you can get help at #rum. I see you've already asked other questions there :thumbsup:
Was just trying to not flood it with nooby questions haha
@kauko is there a standard way to set a property in Rum/Reagent etc?
@joshkh: because namespaces are not seen as objects. So gen
will not work but gen/vector
will.
user=> (require '[clojure.spec.gen :as gen])
nil
user=> gen
java.lang.RuntimeException: Unable to resolve symbol: gen in this context
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: gen in this context, compiling:(/tmp/form-init7595209781886275963.clj:1:8637)
user=> gen/any
#<Fn@10f353c7 clojure.spec.gen/eval31156[any]>
thanks @not-raspberry
is anyone here good with spec? 🙂 i've used gen/generate to create bunch of maps with UUIDs and i'd like to generate (using spec) vectors containing those UUIDs.
#clojure-spec
Does anyone know if there is an equivalent to python's newspaper library in clojure? It looks like enlive might be the right place for me to look (https://github.com/swannodette/enlive-tutorial). Are there others?