beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
euccastro 2021-01-03T00:11:23.389300Z

or you could use that generator to unpredictably shuffle a vector/array of integers mapping to the range AA000 to ZZ999, as you had in mind. they're fewer than a million, so keeping them in memory is doable

ackerleytng 2021-01-03T04:49:29.394700Z

trying to build an uberjar with depstar - I'm getting

clojure -X:depstar uberjar :jar MyProject.jar
2021-01-02 20:48:09.772:INFO::main: Logging initialized @2905ms to org.eclipse.jetty.util.log.StdErrLog
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-X:depstar (No such file or directory)

ackerleytng 2021-01-03T05:04:03.395Z

seems like i needed to update clojure

ackerleytng 2021-01-03T05:13:14.396900Z

when building an uberjar, is the app supposed to be executed? the guide [here](https://github.com/seancorfield/depstar#basic-usage) suggests using :replace-deps , but when I try and build the uberjar, it fails, and the error messages suggest that some dependencies are missing

2021-01-03T05:16:53.397200Z

Yes, the -X option is a recent addition to Clojure CLI

2021-01-03T05:18:45.397400Z

Did you add the depstar alias in your config file? in which one? Please copy it here so we can help.

2021-01-03T05:22:37.397600Z

In case it helps, here is a usage of the previous version: https://github.com/green-coder/girouette/blob/master/deps.edn#L11-L22

ackerleytng 2021-01-03T05:35:14.398100Z

I see 🙂

ackerleytng 2021-01-03T05:37:07.398300Z

:aliases {:uberjar
           {:replace-deps {seancorfield/depstar {:mvn/version "2.0.165"}}
            :replace-paths ["src/clj"]
            :exec-fn hf.depstar/uberjar
            :exec-args {:jar "MyProject.jar"
                        :aot true
                        :main-class project.core}}}

2021-01-03T05:37:47.398500Z

here, you should use the alias uberjar instead of depstar because that’s how you named it.

ackerleytng 2021-01-03T05:38:00.398700Z

oh?? isn't the alias just a name?

ackerleytng 2021-01-03T05:38:39.399Z

let me try that again

ackerleytng 2021-01-03T05:42:05.399200Z

thanks! with that config, I did clojure -X:uberjar and I'm getting an error finding mount , but mount is in my dev/ directory - did i use :replace-paths correctly?

2021-01-03T05:45:34.399900Z

I never used :replace-paths and did not find its documentation on depstar’s page.

Ben Sless 2021-01-03T06:03:45.400300Z

using collections as values does have a hidden cost. While the hash values are cached, at the end of getting from a map there is a comparison between the found key and the provided one (as they might) have the same hash. Comparing collections is very expensive in relation to getting a value from a map

Ben Sless 2021-01-03T06:04:08.400500Z

This is where it happens:

public Object find(int shift, int hash, Object key, Object notFound){
		int bit = bitpos(hash, shift);
		if((bitmap & bit) == 0)
			return notFound;
		int idx = index(bit);
		Object keyOrNull = array[2*idx];
		Object valOrNode = array[2*idx+1];
		if(keyOrNull == null)
			return ((INode) valOrNode).find(shift + 5, hash, key, notFound);
		if(Util.equiv(key, keyOrNull))
			return valOrNode;
		return notFound;
	}

seancorfield 2021-01-03T06:08:43.400700Z

@ackerleytng As the depstar README says: Note: these instructions assume you have at least version 1.10.1.727 of the Clojure CLI installed

seancorfield 2021-01-03T06:09:24.400900Z

clj-new is the same: requires at least 1.10.1.727

ackerleytng 2021-01-03T06:09:47.401100Z

oh thanks! missed that

ackerleytng 2021-01-03T06:10:17.401300Z

https://clojure.org/reference/deps_and_cli#_replace_project_environment_tool <= I thought :replace-paths was a cli/deps.edn thing

seancorfield 2021-01-03T06:10:31.401500Z

@ackerleytng If your app depends on things that you would need to provide aliases for, you need to tell depstar what those aliases are.

2021-01-03T06:10:38.401700Z

> when building an uberjar, is the app supposed to be executed? perhaps unrelated to your error, but a very common misunderstanding is that clojure doesn't have a "compile mode" - if your def has a side effect, it will run while compiling the file

👍 1
🔖 1
seancorfield 2021-01-03T06:11:06.401900Z

See this section of the README:

As of depstar 2.0, the classpath is computed from the system and project deps.edn files. If :repro false, the user deps.edn file is also used. This is intended to correspond to the CLI's -Srepro option that ignores the user deps.edn file. If you need to adjust that classpath, based on aliases, you can supply a vector of aliases to the :aliases exec argument of depstar.

seancorfield 2021-01-03T06:12:35.402100Z

I suspect you have an alias (maybe :dev?) that adds dev/, you need to specify :aliases [:dev] (or whatever that alias is).

ackerleytng 2021-01-03T06:15:41.402300Z

I added dev/ to :paths in the deps.edn and i was going to :replace-paths when building the uberjar

ackerleytng 2021-01-03T06:16:36.402500Z

do you recommend removing dev from :paths and then adding it using an alias for dev purposes?

seancorfield 2021-01-03T06:18:39.402900Z

If something needs to be in your final app, it probably shouldn't be under a separate alias -- it should be in your core :paths value (and you wouldn't use :replace-paths).

ackerleytng 2021-01-03T06:19:57.403200Z

i only need the stuff in the dev/ directory for dev, so it shouldn't be in the final app

seancorfield 2021-01-03T06:19:59.403400Z

(it's very rare that you would ever need :replace-paths)

dpsutton 2021-01-03T06:20:02.403600Z

including dev in an uberjar just sounds weird to me

seancorfield 2021-01-03T06:20:34.403800Z

Agreed. But it sounds like you have stuff in your main code that refers to things that are in your dev folder -- which doesn't sound right @ackerleytng

2021-01-03T06:20:48.404Z

this is a great point, but also note that the collection equality check is cheap if the key used for lookup and the key in the map are the same object in memory

dpsutton 2021-01-03T06:21:07.404200Z

> I'm getting an error finding mount , but mount is in my dev/ directory can you explain what you mean in this sentence?

dpsutton 2021-01-03T06:21:19.404400Z

what does finding mount mean?

ackerleytng 2021-01-03T06:21:31.404600Z

I think it could be because i originally put dev/ in :paths, which puts it in the final app.

ackerleytng 2021-01-03T06:21:53.404800Z

mount is this dependency https://github.com/tolitius/mount

dpsutton 2021-01-03T06:22:12.405100Z

sure. what does "finding mount" mean?

dpsutton 2021-01-03T06:22:32.405300Z

and how is mount in your dev/ directory

ackerleytng 2021-01-03T06:26:20.407300Z

oh wait mount is a dependency in my ~/.clojure/deps.edn and [mount.core :as mount :refer [defstate] referenced in dev/user.clj

dpsutton 2021-01-03T06:30:09.410200Z

that's a bit strange. if you depend on mount, add it as a dependency. seems strange to have that only in dev and not throughout the app. not sure what its purpose is there

Rowan Barnard 2021-01-03T06:30:36.410700Z

Hi everyone and I wish a happy new year to all 🙂 I've been working through the book Living Clojure but I'm now stuck on the chapter where we mix cljs code with clj code - I can't get the cljs repl to run - I enter the line the book tells me lein trampoline cljsbuild repl-rhino on the Windows commandline and it tells me Syntax error (FileNotFoundException) compiling at (cljsbuild\repl\rhino.clj:1:1). Could not locate cljs/repl/rhino__init.class, cljs/repl/rhino.clj or cljs/repl/rhino.cljc on classpath. Any ideas what I might be doing wrong?

ackerleytng 2021-01-03T06:32:14.410900Z

in my app, i start jetty from main directly

seancorfield 2021-01-03T06:32:31.411400Z

Well, if your uberjar is failing because it's looking for mount then, yup, it should be a core dependency in the project. I can't imagine how you'd build an app that only uses mount at dev time -- it's kind of intrusive with its global state (which is why I won't use it).

ackerleytng 2021-01-03T06:32:32.411600Z

but i use mount for development so i can stop jetty and restart it

seancorfield 2021-01-03T06:33:17.411900Z

If you really think you're only using mount at development time then you absolutely do not need to use mount at all.

dpsutton 2021-01-03T06:33:27.412100Z

but if mount isn't sprinkled throughout the app, aren't you just calling a single start and stop on the server? if its not really dealing with dependencies its just an alias for the start and stop of the server

seancorfield 2021-01-03T06:33:32.412300Z

You can easily stop/start jetty directly.

dpsutton 2021-01-03T06:33:44.412500Z

i think the rhino repl was removed from clojurescript recently (ish). That's a pretty old style to get up and running

dpsutton 2021-01-03T06:34:08.412900Z

one possibility is that it should work if you use the version of clojurescript that's in use in the book

dpsutton 2021-01-03T06:36:06.413500Z

i see a repo from the author working through one of the examples at https://github.com/gigasquid/cheshire-cat which specifies a clojurescript version [org.clojure/clojurescript "0.0-2371"]

ackerleytng 2021-01-03T06:36:39.413800Z

ohh i see. would it be like (def server (run-jetty ...)) and then if i need to stop it, do (.stop server)?

dpsutton 2021-01-03T06:38:56.415300Z

from github i see that was released on october 9, 2014 and is so old that all of the tooling around it is very out of date. the tutorial itself might still be valid but i haven't seen it. the author's very interesting and done some of my favorite exploratory and fun coding (chemical computing: https://gigasquidsoftware.com/chemical-computing/index.html)

dpsutton 2021-01-03T06:39:22.415400Z

yeah. i'm guessing that's what you have in your dev namespace right?

dpsutton 2021-01-03T06:39:39.415600Z

(defstate ...)

seancorfield 2021-01-03T06:40:04.416300Z

I didn't think Living Clojure was that old, but I've sort of lost track of when various books were released at this point...?

seancorfield 2021-01-03T06:40:56.416800Z

April 2015. Wow. Almost six years ago!

seancorfield 2021-01-03T06:41:38.417600Z

Given my recent experience, coming back to cljs after last looking at it in 2014, things have really changed in the cljs world...

ackerleytng 2021-01-03T06:42:27.417700Z

yup that's what i have!

ackerleytng 2021-01-03T06:42:29.417900Z

thanks i'll remove mount

seancorfield 2021-01-03T06:42:44.418200Z

Remove mount completely from your memory 🙂

ackerleytng 2021-01-03T06:43:02.418700Z

🙂

Rowan Barnard 2021-01-03T06:45:05.420300Z

Ah OK thanks dpsutton, sean, might try specifying the same clojurescript version as is in the book then so hopefully that should work or I will need to figure out how to do it the modern way

Rowan Barnard 2021-01-03T06:46:41.422100Z

I didn't know how to get started with a ring server and mixed clj/cljs with deps.edn so just followed along with the book's Leiningen instructions also, would be nice to know how to do it with deps.edn if there is anything easy I can look at?

dpsutton 2021-01-03T06:47:25.422600Z

i'd check out figwheel main's documentation and look for a template with it built in

Rowan Barnard 2021-01-03T06:48:14.423100Z

OK thanks, I'll have a look at that 😉

seancorfield 2021-01-03T06:54:49.424900Z

@flyingpython I am just getting started with ClojureScript (it's all so different to when I last looked at it that I'm a beginner all over again), and I'm liking Figwheel Main, and as you know I'm using deps.edn. I don't have a combined front + back end app together yet but I'm working on getting something basic together that I'll probably use as a model for what I need to build at work...

seancorfield 2021-01-03T06:55:21.425500Z

I'll put it up in a public repo when I have something working end-to-end.

seancorfield 2021-01-03T06:55:42.426200Z

(and of course I'm making this all work with Reveal and Atom/Clover)

Rowan Barnard 2021-01-03T06:55:43.426400Z

OK that sounds promising Sean, not sure if I'll be able to understand it though?

seancorfield 2021-01-03T06:58:11.426800Z

Happy to talk you through it, once I get it all up and running 🙂

Rowan Barnard 2021-01-03T06:58:44.427500Z

OK thank you very much, I will look forward to having a look at it 😉

Rowan Barnard 2021-01-03T07:01:16.430Z

At this point in the book I just need something equivalent to lein ring server and getting a ClojureScript REPL up and running (especially if I can do this with Clover/Chlorine) I've been using Chlorine and deps.edn config throughout the book until I got to this chapter as I was unsure how to translate it from Leiningen to deps.edn and socket REPL setup

seancorfield 2021-01-03T07:03:52.430400Z

@flyingpython Figwheel is pretty easy to use with deps.edn and the Clojure CLI.

seancorfield 2021-01-03T07:04:57.431900Z

I used a figwheel-main-template, told it I wanted a --reagent app. Then clojure -M:fig:build and I was up and running.

Rowan Barnard 2021-01-03T07:05:26.432400Z

:thumbsup: That's great; I like easy!

seancorfield 2021-01-03T07:05:56.433100Z

(then I added re-frame and converted it from Reagent to re-frame; next I plan to add an http lib so I can call from the front end to the back end I'll build)

seancorfield 2021-01-03T07:08:40.434300Z

It is on GitHub but I haven't updated the readme at all so it's not accurate. I'm still poking at tooling and figuring out how best to work with this new-to-me ecosystem 🙂

seancorfield 2021-01-03T07:11:21.436700Z

I have updated my dot-clojure files to work with figwheel and reveal tho'... (and I updated that readme to cover some of this)

Rowan Barnard 2021-01-03T07:12:11.437200Z

OK, sounds cool, just drop a line on the Chlorine channel or something like that when you have it updated and I'll have a look though I'll probably look soon anyway for lack of patience 😃

ackerleytng 2021-01-03T07:13:24.438Z

would people recommending having a single deps.edn for both frontend and backend?

dpsutton 2021-01-03T07:14:26.438300Z

i don't think there's a mechanism to have two. so yes

ackerleytng 2021-01-03T07:15:38.440500Z

how should i set up paths? the paths are mostly different, right?

Rowan Barnard 2021-01-03T07:17:01.444400Z

Hmm, I've seen projects with more than one deps.edn in them though - maybe the other deps file was just an old artifact they weren't using anymore though if it is indeed the case you can't use more than one

dpsutton 2021-01-03T07:17:09.444700Z

you could do src/frontend and src/backend. leads to some awkward bits when you have shared code

dpsutton 2021-01-03T07:17:22.445400Z

@flyingpython if they had more than one deps.edn, what were the filenames?

ackerleytng 2021-01-03T07:17:43.446300Z

oh i meant :paths in deps.edn

ackerleytng 2021-01-03T07:18:53.449600Z

figwheel seems to be expecting paths defined in :paths, which means when i build the uberjar i have to override paths...? does that sound right?

2021-01-04T00:26:17.063300Z

there should be no trace of figwheel in the uberjar - figwheel is a dev time tool and in your final artifact you should just have the javascript that cljsbuild outputs

ackerleytng 2021-01-04T00:34:59.063700Z

yup! my deps.edn file has both frontend and backend stuff in it. i think i figured it out, here's my final deps.edn https://github.com/ackerleytng/gowherene/blob/master/deps.edn

Rowan Barnard 2021-01-03T07:19:19.450700Z

I can't remember the filenames as it was in the past I saw it, they were in different folders in the project though, I assume the filenames were both deps.edn as I am pretty sure that is what I saw but could be wrong given the fallibility of human memory and all

Jakub Zika 2021-01-03T07:20:03.451700Z

@flyingpython this is a nice & relevant book about clj / cljs integration (lein, shadow-cljs, raegent and re-frame,..). Still in beta though. https://pragprog.com/titles/dswdcloj3/web-development-with-clojure-third-edition/

dpsutton 2021-01-03T07:21:26.453500Z

ah. yeah i've seen that. and a top level one that uses the sub projects with :local/root. an example is chui: https://github.com/lambdaisland/chui

seancorfield 2021-01-03T07:22:30.455400Z

Figwheel should only care what is on the classpath when you run it -- which you can control with aliases.

Rowan Barnard 2021-01-03T07:22:43.455800Z

OK thanks for the recommendation, I would prefer one with deps.edn though as that is what I've mostly been what I've been using though and I prefer it once I got started, Leiningen is easier to jump in and start with, but I find with deps.edn it seems less magical to me as to what is going on

seancorfield 2021-01-03T07:24:08.457200Z

It's certainly reasonable to have :client and :server aliases that specify different paths (and you can still have shared code -- specified in both aliases' :replace-paths or :extra-paths (I'd probably use the latter and have the main :paths just be the shared code).

seancorfield 2021-01-03T07:25:02.457800Z

And when you build the (backend) uberjar, just tell depstar to use :aliases '[:server]'

seancorfield 2021-01-03T07:26:00.458900Z

And for the front end: clojure -M:client:fig:build should work for development (and clojure -M:client:fig:min for a "prod" build, if I'm reading the figwheel template right).

seancorfield 2021-01-03T07:26:41.459600Z

And then a separate REPL to run the server: clj -M:server -r (plus whatever other aliases you want).

seancorfield 2021-01-03T07:28:02.460900Z

(for me, the only quirk would that my dev tooling assumes it can write a single .socket-repl-port file into the project, so I would probably spin up both the client and the server together via figwheel and my :dev/repl alias while developing)

seancorfield 2021-01-03T07:29:12.462100Z

(something like clojure -M:client:server:reveal:test:fig:build:dev/repl I think, maybe with :add-libs as well depending on whether I thought I might want to add new dependencies after starting my REPL)

dpsutton 2021-01-03T07:30:10.462400Z

goodness that's quite an incantation 🙂

seancorfield 2021-01-03T07:30:43.462800Z

Easy enough to hide via a shell script or a bash alias 🙂

seancorfield 2021-01-03T07:31:14.463500Z

I think my main REPL startup command at work has even more aliases in it. At least they compose nicely 🙂

Ben Sless 2021-01-03T07:32:18.464800Z

True, for every other case, however, I have seen a sharp drop off in performance when hashing collections, making it a non-starter for anything which requires speed or high throughput =\ A plausible middle ground is creating synthetic keys via different methods, either string concatenation or keyword generation

Rowan Barnard 2021-01-03T07:33:37.466200Z

@dpsutton OK yeah, I think like that lamdaisland example but I see there's a simple example on the https://clojure.org/guides/deps_and_cli page under "Using local libraries" they include part of their program as a library which has it's own deps.edn so I am thinking you can use as many deps.edns as you like so long as the source code and deps files are in their own separate folders

seancorfield 2021-01-03T07:35:24.467300Z

OK, I'm out for the night. I'll try to carve out some time tomorrow to add a server component to my little re-frame repo and write up the readme so it's all up-to-date.

dpsutton 2021-01-03T07:35:29.467500Z

yeah. its quite readable. and for sure a little alias or shell script would fix it

Rowan Barnard 2021-01-03T07:36:19.469Z

OK good night Sean, thanks for the help 😉

seancorfield 2021-01-03T07:36:21.469100Z

(now that I've incorporated a lot of the individual pieces into :dev/repl and it adapts to whatever is on your classpath, my dev setup is a lot easier!)

Rowan Barnard 2021-01-03T07:36:40.469600Z

Oh that sounds great!

dpsutton 2021-01-03T07:36:45.469700Z

i do wish cider worked with socket repls. alas

seancorfield 2021-01-03T07:37:11.470100Z

Once they have side-loading, that should be easy to do.

seancorfield 2021-01-03T07:38:21.471300Z

Chlorine/Clover side-load unrepl over a socket REPL (and Christophe was working with Bug on doing something similar with nREPL I believe).

seancorfield 2021-01-03T07:38:46.471500Z

Anyways. Bed.

flowthing 2021-01-03T08:12:38.474600Z

FWIW, nREPL already has a sideloader, but it can’t inject itself over a socket REPL yet. Here’s the GitHub issue for it: https://github.com/nrepl/nrepl/issues/96

caumond 2021-01-03T08:56:49.477600Z

hi guys, I don't know where to ask. I'm working with toolnamespace/refresh function. It seems to be broken, no file modification is detected anymore. Don't know what to do, where to look. I remove main from my profile, as some advise.

caumond 2021-01-03T08:59:31.478500Z

Just in case, I restart my repl, started with a fresh copy of my repo....

caumond 2021-01-03T10:09:56.480Z

I did not understand all the subtlety, but it appears my refactor-nrepl / cider-nrepl and tools.namespace were conflicting.

caumond 2021-01-03T10:11:13.480600Z

It works now I am using a cider-jackin as recommended https://github.com/clojure-emacs/refactor-nrepl#with-cider-and-clj-refactor

gibi 2021-01-03T10:53:11.481400Z

hi, how can I retrieve vectors instead of lists when using partition ? Thanks

caumond 2021-01-03T10:54:10.482Z

Hi, in my understanding you can't directly, but you can retransform them to vector

caumond 2021-01-03T10:55:02.482200Z

(map #(into [] %) (partition 2 [1 2 3 4]))

🙌 2
caumond 2021-01-03T10:55:30.482700Z

is it answering your question?

caumond 2021-01-03T10:55:46.483Z

Yees, I got it, you're the first I help !

gibi 2021-01-03T10:56:17.483300Z

😄 thanks @caumond

2021-01-03T10:57:32.484Z

@francesco.losciale Or more concisely (map vec (partition 2 [1 2 3 4]))

👍 2
william 2021-01-03T11:02:20.487500Z

question on clojure.spec: when I do something like (s/def ::myspec ...) what am I actually defining? What trips me is that that's not a variable, so I'm not sure how I should use it from another file. Doing something like:

(s/conform (s/coll-of myfile/myspec) collection)
doesn't work (use of undeclared var)

caumond 2021-01-03T11:03:59.488500Z

when you declare s/def ::myspec you fullfill a https://clojure.org/guides/spec#_registry which key is the keyword

caumond 2021-01-03T11:04:29.489100Z

your example does not because s/coll-of does not seem to call the keyword

william 2021-01-03T11:05:02.489700Z

thanks, and how would I refer to that spec to conform some data in another file?

caumond 2021-01-03T11:05:40.490Z

try

(s/def ::tst int?)
(s/conform (s/coll-of ::tst) [1 2])

william 2021-01-03T11:06:18.491100Z

I got it now! Your example wouldn't work for me, but :myfile/myspec would! It's just a keyword!

william 2021-01-03T11:06:30.491400Z

thanks for the help @caumond! 🙂

caumond 2021-01-03T11:06:37.491700Z

to refer an external keyword, you need to specify the full qualify name

caumond 2021-01-03T11:06:43.491900Z

yes, that's it

caumond 2021-01-03T11:06:57.492300Z

have a look also to ::myfile/myspec syntax

caumond 2021-01-03T11:07:26.493200Z

very helpful to use :as in your require`

caumond 2021-01-03T11:07:51.493800Z

(require [myfile :as m])
::m/myspec

caumond 2021-01-03T11:08:21.494100Z

it was my last wednesday breakthrough, (;p

william 2021-01-03T11:08:35.494400Z

hahaha, very good points, thanks again 🙏

caumond 2021-01-03T11:09:54.495500Z

no pb, us guys are sleeping, so early I have opportunities to appear knowledgeable

😂 2
Christian 2021-01-03T11:26:37.496700Z

Normally, when I have a hash-map, I can look up if a key exists and I can see all values. With a transient hash-map that does not work. How would I solve this?

(vals {:a 1 :b 2})
;; =&gt; (1 2)

(vals (transient {:a 1 :b 2}))
; Execution error (IllegalArgumentException) at robot-name/eval29220 (form-init8682869554046594837.clj:59).
; Don't know how to create ISeq from: clojure.lang.PersistentArrayMap$TransientArrayMap

roelof 2021-01-03T11:41:59.497300Z

I think Im complicating things here to solve this challenge

; Write a function, validate, which will check that :name and :glitter-index are
; present when you append. The validate function should accept two arguments: 
; a map of keywords to validating functions, similar to conversions, and the
; record to be validated.
 
(def validation {:name validate-name
                 :glitter-index validate-index})

(defn validate
  [validators suspect]
   (and (get suspect key) ((get validators key) (get suspect key))))

roelof 2021-01-04T09:49:08.071600Z

or is this what you are looking for :

(defn validate2
  [validators suspect]
  (reduce-kv (fn[acc k v]
               (and acc                            ;; The previous keys were validated
                    (contains? suspect k)   ;; the suspect contains the key in question
                    (v (suspect k))))            ;; the value of that key in the suspect validates according to the validator function
             true validators))                    ;; you want to check all validators, so you reduce over them

 (defn validate-name[name]
  (print name)
  (and (string? name) (&gt; (count name) 3)))
I made this with some help of another person

roelof 2021-01-04T09:51:55.071800Z

@pavlos

pavlosmelissinos 2021-01-04T09:57:34.072Z

Does it work?

roelof 2021-01-04T09:58:14.072200Z

yep

pavlosmelissinos 2021-01-04T10:01:43.072400Z

Are you sure? How did you test it?

roelof 2021-01-04T10:02:51.072600Z

with this in repl

(validate2 {:name validate-name} {:name "a"})
;; =&gt; false


(validate2 {:name validate-name} {:name "aaaaa"})

roelof 2021-01-04T10:17:44.072800Z

and this two give the right answer

👌 1
roelof 2021-01-03T11:42:08.497700Z

do you experts agree ?

caumond 2021-01-03T11:44:16.498300Z

@christiaaan, I don't know too much about transient but it seems they are not compatible with all operations

caumond 2021-01-03T11:44:31.498700Z

usually, you have a x! version of operators

pavlosmelissinos 2021-01-03T12:31:25.498800Z

key is undefined, what is it meant to represent?

roelof 2021-01-03T12:34:39.499Z

a record looks like this {:name: "John Doe" , glitter-index: 2}

roelof 2021-01-03T12:35:12.499200Z

so as far as I see it , key is first name and then glitter-index

roelof 2021-01-03T12:35:22.499400Z

@pavlos

pavlosmelissinos 2021-01-03T12:43:10.000100Z

Yup that makes sense. What's your question then?

roelof 2021-01-03T12:44:50.000300Z

my question is that I think Im overcomplicating things. Am I right with that ?

roelof 2021-01-03T12:45:17.000500Z

as far as I see if I have to check if the keywords are there and if they are not empty

pavlosmelissinos 2021-01-03T12:56:13.000700Z

(Besides any errors in logic) your solution is not valid clojure because key is unbound. It does seem a bit too complicated but to be honest I can't tell where you're going with it, so I can't answer your question, sorry. The description is a bit vague too (e.g. what does when you append refer to?) Anyway, the exercise seems to consist of two parts. Why don't you try completing them one by one? Leave the second argument aside and try to focus on the first sentence: > Write a function, validate, which will check that :name and :glitter-index are > present [in a record]

roelof 2021-01-03T13:04:55.001100Z

I will try that

teodorlu 2021-01-03T13:24:17.001800Z

I have a type: (defrecord Point [x y]) How can I get a list of all the protocols Point implements?

teodorlu 2021-01-03T13:26:58.001900Z

(ancestors Point)
#{clojure.lang.Counted java.lang.Iterable java.util.Map java.io.Serializable
  clojure.lang.IObj clojure.lang.IRecord clojure.lang.Associative
  clojure.lang.ILookup clojure.lang.IMeta clojure.lang.IPersistentCollection
  java.lang.Object clojure.lang.Seqable clojure.lang.IKeywordLookup
  clojure.lang.IHashEq clojure.lang.IPersistentMap}
✔️

teodorlu 2021-01-03T13:29:21.002100Z

now, which one lets me do :keys [x y] destructuring? :thinking_face:

teodorlu 2021-01-03T13:29:42.002300Z

ILookup?

teodorlu 2021-01-03T13:30:32.002500Z

user=&gt; clojure.lang.ILookup
clojure.lang.ILookup
user=&gt; (doc clojure.lang.ILookup)
Syntax error compiling var at (REPL:1:1).
Unable to resolve var: clojure.lang.ILookup in this context

teodorlu 2021-01-03T13:37:21.003900Z

Where's the best place to find docs about protocols and interfaces from Clojure core and clojure.lang? https://clojurians.slack.com/archives/C053AK3F9/p1609680670002700?thread_ts=1609680257.001800&amp;cid=C053AK3F9

teodorlu 2021-01-03T13:51:49.004100Z

I'm starting here: https://www.youtube.com/watch?v=vZtkqDIicqI&amp;feature=youtu.be

popeye 2021-01-03T14:03:05.005200Z

I have input which gives out put in below way

(filter some? [[7 6 8] 3 4 nil nil)
([7 6 8] 3 4)

popeye 2021-01-03T14:03:29.005800Z

how can i get destructing out put like (7 8 6 3 4)

2021-01-03T14:04:45.005900Z

I suggest flatten

🙌 1
pavlosmelissinos 2021-01-03T14:08:02.006100Z

flatten should work but take a look at this discussion too: https://stackoverflow.com/questions/25182904/clojure-why-is-flatten-the-wrong-thing-to-use

popeye 2021-01-03T14:20:32.006500Z

@pavlos I ran this

(flatten [ 5 6 {:a "v" :b "a" } nil 4 nil nil 5 nil :a [ 2 3] ])

popeye 2021-01-03T14:21:28.006800Z

the result is expected, it did not destruct the map, but it destructed vector.. Is still fine right?

1
pavlosmelissinos 2021-01-03T14:53:23.007200Z

All that matters in the end is whether your solution gives you the expected result. In an exercise like this I think it's fine but in real world problems, when flatten is the most obvious solution then there's a good chance something is wrong with your data model.

👍 2
Harley Waagmeester 2021-01-03T15:20:02.007900Z

you might try (flatten .......)

Harley Waagmeester 2021-01-03T15:21:45.008700Z

i.e. (flatten (filter some? [[7 6 8] 3 4 nil nil))

Harley Waagmeester 2021-01-03T15:21:54.009Z

lemme try it here..

Harley Waagmeester 2021-01-03T15:25:02.009200Z

(flatten (filter some? [[7 6 8] 3 4 nil nil]))

Harley Waagmeester 2021-01-03T15:25:09.009400Z

seems to work

Harley Waagmeester 2021-01-03T15:25:41.009800Z

flatten is an old trick from lisp

roelof 2021-01-03T15:31:55.010Z

hmm no luck

roelof 2021-01-03T15:32:04.010200Z

(defn validate
  [validators suspect]
    (every?  #(contains? validators %) suspect))


  
(validate [:name] {:name "toto"})

roelof 2021-01-03T15:32:23.010400Z

it gives now false where I expect to be true

pavlosmelissinos 2021-01-03T15:44:27.010600Z

Keep simplifying the requirements until you can come up with a solution and build up from that! e.g. a good starting point could be: > Write a function that has a single input (the record) and checks that :name is present in that record

2021-01-03T15:48:16.011500Z

The main caution about flatten is that if you have anything more deeply nested than that, it usually flattens more than you want.

roelof 2021-01-03T15:56:47.011600Z

thanks

roelof 2021-01-03T15:56:53.011800Z

I hope I did now a good job

roelof 2021-01-03T15:56:59.012Z

; Write a function, validate, which will check that :name and :glitter-index are
; present when you append. The validate function should accept two arguments: 
; a map of keywords to validating functions, similar to conversions, and the
; record to be validated.

(defn validate
  [validators suspect]
    (every?  #(contains? suspect %) validators))

roelof 2021-01-03T15:58:06.012200Z

the functions that the text is talking about

(def conversions {:name identity
                  :glitter-index str-&gt;int})

(defn convert
  [vamp-key value]
  ((get conversions vamp-key) value))

pavlosmelissinos 2021-01-03T16:04:04.012400Z

yup, you're halfway there

pavlosmelissinos 2021-01-03T16:04:08.012600Z

contains? is not very idiomatic for key lookup in maps (and it throws people off when it's applied to lists/vectors), get is more natural

roelof 2021-01-03T16:05:41.012900Z

oke, changed it and why am i half way there ?

pavlosmelissinos 2021-01-03T16:05:56.013100Z

validators needs to be a map, not a vector

pavlosmelissinos 2021-01-03T16:06:36.013300Z

> a map of keywords to validating functions

roelof 2021-01-03T16:10:41.013500Z

hmm back to the book

(defn validate
  [validators suspect]
    (every?  #(get suspect %) validators))


(defn validate-name[] true)

(validate {:name validate-name} {:name "toto"})

roelof 2021-01-03T16:10:45.013700Z

gives now false

roelof 2021-01-03T16:16:33.013900Z

and now I Cannot check for :name alone

roelof 2021-01-03T16:16:44.014100Z

it has to have a second thing into it

pavlosmelissinos 2021-01-03T16:19:22.014300Z

that's not a map

roelof 2021-01-03T16:20:47.014500Z

it is not ?

roelof 2021-01-03T16:20:52.014700Z

now im confused

roelof 2021-01-03T16:21:17.014900Z

I learned that a map look like this : `

{:key "value"}

roelof 2021-01-03T16:21:26.015100Z

and I have used that as far as I know

flowthing 2021-01-03T16:23:38.016Z

There’s also the faintly JavaScripty (flatten 1) etc.

pavlosmelissinos 2021-01-03T16:25:15.016200Z

Nevermind, you're right

roelof 2021-01-03T16:25:27.016400Z

ok, no problem

roelof 2021-01-03T16:26:10.016600Z

I also thought you mean this :

(validate {:validator [:name]} {:name "toto"})

roelof 2021-01-03T16:26:37.016800Z

but then I think I need to rewrite this one

(defn validate
  [validators suspect]
    (every?  #(get suspect %) validators))

pavlosmelissinos 2021-01-03T16:27:07.017Z

The validator needs to be a map of keywords to functions

roelof 2021-01-03T16:27:53.017200Z

oke

pavlosmelissinos 2021-01-03T16:28:00.017400Z

so it needs to look more like the first version (`{:name validate-name}`) and less like the second (`{:validator [:name]}`)

roelof 2021-01-03T16:28:13.017600Z

(defn validate
  [validators suspect]
    (every?  #(get suspect %) validators))


(defn validate-name[] true)

(validate {:name validate-name} {:name "toto"})
but then I wonder why this is given false

roelof 2021-01-03T16:28:32.017800Z

the name is there and the validate function gives also true

pavlosmelissinos 2021-01-03T16:29:08.018Z

every? works with sequences

roelof 2021-01-03T16:29:43.018200Z

got it I think

roelof 2021-01-03T16:29:50.018400Z

(defn validate
  [validators suspect]
    (every?  #(get suspect %) (validators key)))


(defn validate-name[] true)

(validate {:name validate-name} {})

pavlosmelissinos 2021-01-03T16:30:45.018600Z

this works but here's the thing

pavlosmelissinos 2021-01-03T16:30:53.018800Z

what's the point of the validator functions?

pavlosmelissinos 2021-01-03T16:31:11.019Z

shouldn't you be using those to validate the values?

roelof 2021-01-03T16:31:27.019300Z

to see if the name is according to a certain thing

roelof 2021-01-03T16:31:49.019500Z

yep, but the challenge is not saying what the name should do to be valid

roelof 2021-01-03T16:31:55.019700Z

or I have to make things up

roelof 2021-01-03T16:32:36.019900Z

I could make code to say it has to be a string and longer then 4 characters but that is made up

roelof 2021-01-03T16:32:52.020100Z

no idea if that is a problem or I have to freedom

pavlosmelissinos 2021-01-03T16:33:33.020300Z

it's an exercise isn't it? it's up to you

pavlosmelissinos 2021-01-03T16:34:06.020500Z

You can also move the logic of get to the validator function

pavlosmelissinos 2021-01-03T16:34:27.020700Z

but then it wouldn't exactly check for membership

2021-01-03T16:34:55.021700Z

In Clojure? Or some 3rd party lib?

flowthing 2021-01-03T16:35:14.022Z

Clojure.

pavlosmelissinos 2021-01-03T16:35:22.022200Z

e.g. should this be true or false? (validate {:name validate-name} {:name nil})

flowthing 2021-01-03T16:35:37.022700Z

Returns ().

roelof 2021-01-03T16:37:12.022900Z

I would say false

pavlosmelissinos 2021-01-03T16:37:23.023100Z

btw this is the difference of contains? and get as well

pavlosmelissinos 2021-01-03T16:38:16.023300Z

(contains? {:name nil} :name) => true but (get {:name nil} :name) => nil

roelof 2021-01-03T16:38:46.023600Z

thanks

roelof 2021-01-03T16:39:22.023800Z

got a bug somewhere

(defn validate
  [validators suspect]
    (every?  #(get suspect %) (validators key)))


(defn validate-name[name]
  (and (string? name) (&gt; (count name) 3)))

(validate {:name validate-name} {:name "aa"})
this gives true but 2 is smaller then 3 so it should be false

pavlosmelissinos 2021-01-03T16:43:25.024Z

you're not calling the validator function anywhere

pavlosmelissinos 2021-01-03T16:43:47.024200Z

you need to apply the function to the value of the record

pavlosmelissinos 2021-01-03T16:44:24.024400Z

(every? #(get suspect %) (validators key)) this does not work anymore

pavlosmelissinos 2021-01-03T16:46:28.024600Z

also what do you think (validators key) does?

roelof 2021-01-03T16:46:32.024800Z

I thought that

roelof 2021-01-03T16:47:07.025Z

I thought I get the key like name out of it

pavlosmelissinos 2021-01-03T16:47:50.025200Z

key works on map entries, not whole maps

pavlosmelissinos 2021-01-03T16:49:24.025400Z

you can get the full key set of a map with keys

roelof 2021-01-03T16:50:57.026200Z

oke

roelof 2021-01-03T16:51:05.026500Z

then there is another problem

roelof 2021-01-03T16:51:16.026900Z

(defn validate
  [validators suspect]
    (every?  #(get suspect %) (validators keys)))


(defn validate-name[name]
  (and (string? name) (&gt; (count name) 3)))

(validate {:name validate-name} {:name "aa"})

roelof 2021-01-03T16:51:30.027300Z

gives still true where I expect to be false

Andrew Doolittle 2021-01-03T16:52:23.028400Z

Good morning all. My cider repl started printing the entire stack trace every time a function is called and even while I'm typing. This is separate from the regular error stack trace. How can I disable this?

pavlosmelissinos 2021-01-03T16:52:37.028700Z

you're not using validate-name anywhere

pavlosmelissinos 2021-01-03T16:52:57.028900Z

how do expect it to be false? 😛

roelof 2021-01-03T16:53:56.029100Z

I see it

roelof 2021-01-03T16:54:43.029300Z

pff I have to think about that one. I thought (apply validators keys) could help me but it does not

pavlosmelissinos 2021-01-03T16:56:51.029600Z

ok so the values of validators are functions that you need to apply to the values of the record

roelof 2021-01-03T16:57:19.029800Z

yep

pavlosmelissinos 2021-01-03T16:57:25.030Z

apply is a figure of speech, I'm not referring to the actual clojure function

roelof 2021-01-03T16:57:52.030200Z

and Im still thinking I have to do something with this part #(get suspect %)

pavlosmelissinos 2021-01-03T16:58:05.030400Z

yup, that's the culprit

roelof 2021-01-03T16:58:37.030600Z

im thinking that that one give me the function

pavlosmelissinos 2021-01-03T16:59:23.030800Z

#(get suspect %) gives you the value of the record for a particular key

roelof 2021-01-03T17:00:02.031100Z

and then im stuck how I can pass the name or the glitter-index to it

pavlosmelissinos 2021-01-03T17:00:28.031300Z

one problem at a time

pavlosmelissinos 2021-01-03T17:01:09.031500Z

So if the key is :name, what do you want instead of just #(get suspect %) ?

pavlosmelissinos 2021-01-03T17:01:20.031700Z

to actually use the validator

roelof 2021-01-03T17:01:47.031900Z

call it ?

pavlosmelissinos 2021-01-03T17:02:00.032100Z

yep but how?

roelof 2021-01-03T17:02:37.032300Z

normally I do somehing like this : (validate_name "John")

pavlosmelissinos 2021-01-03T17:03:26.032600Z

Correct but now you don't have access to the actual function name.

pavlosmelissinos 2021-01-03T17:03:40.032800Z

You have the key of the validator instead (`:name`), how would you get the function using that?

roelof 2021-01-03T17:04:14.033Z

using get ?

pavlosmelissinos 2021-01-03T17:05:00.033200Z

yes, how would you write that in code?

roelof 2021-01-03T17:05:07.033400Z

so something like (get validators(get suspect %)

pavlosmelissinos 2021-01-03T17:05:45.033600Z

(get suspect %) gives you the value that you want to validate so that's one thing on its own

pavlosmelissinos 2021-01-03T17:06:13.033800Z

you can get the function in a similar way: (get validators %)

roelof 2021-01-03T17:07:13.034Z

oke,

pavlosmelissinos 2021-01-03T17:07:14.034200Z

So now that you have the function and its parameter, how do you build the actual call?

roelof 2021-01-03T17:07:46.034400Z

So I need

(every?  #(get suspect %) (get validators %) (validators keys)))

roelof 2021-01-03T17:07:47.034600Z

?

dpsutton 2021-01-03T17:08:13.035200Z

i think this is an issue with an older version of CIDER. Its making a call to get the clojure-docs and its failing

pavlosmelissinos 2021-01-03T17:08:37.035300Z

the syntax of every? is (every? f coll)

roelof 2021-01-03T17:09:00.035500Z

I saw it when I tried that one

roelof 2021-01-03T17:11:27.035700Z

(defn validate
  [validators suspect]
    (and  (every?  #(get suspect %) (validators keys))(every?  #(get validators %) (validators keys))))
  
still do not work as I expect

roelof 2021-01-03T17:11:45.035900Z

be back after dinner/supper

roelof 2021-01-03T17:11:52.036100Z

thanks so far

pavlosmelissinos 2021-01-03T17:13:24.036300Z

No offense, but it seems to me like you try random things when you get stuck. Try to understand why stuff doesn't work first instead.

roelof 2021-01-03T17:14:03.036500Z

i take no offense

roelof 2021-01-03T17:14:21.036700Z

I was thinking about two clauses and combine them with a and

roelof 2021-01-03T17:14:47.036900Z

so the keys must be there and the validating must return true

roelof 2021-01-03T17:15:02.037100Z

otherwise the record is not valid

roelof 2021-01-03T17:17:38.037300Z

(and  (every?  #(get suspect %) (validators keys)) (every?  #(get validators %) suspect)))

roelof 2021-01-03T17:18:07.037500Z

looks better to me but no everything is false and the validate function is still not called

roelof 2021-01-03T17:18:35.037700Z

Still think I miss some knowlegde what the brave book is trying to teach me

pavlosmelissinos 2021-01-03T17:18:42.037900Z

I can't follow your train of thought

roelof 2021-01-03T17:19:11.038100Z

we have 2 things to test if the record is valid

pavlosmelissinos 2021-01-03T17:19:22.038300Z

what you want to do is: 1. for every key in validators 2. validate the value of record for that key

roelof 2021-01-03T17:19:26.038500Z

1. the keys schould be there

roelof 2021-01-03T17:19:47.038700Z

2. test if the value of the keys is valid according to a function I made up

roelof 2021-01-03T17:20:22.038900Z

1. is done by this piece (every?  #(get suspect %) (validators keys)) , Right

roelof 2021-01-03T17:20:36.039100Z

2 is stil something I think I miss a piece

pavlosmelissinos 2021-01-03T17:21:53.039300Z

you might not need 1

pavlosmelissinos 2021-01-03T17:22:09.039500Z

because if the key isn't there the validation will also fail

pavlosmelissinos 2021-01-03T17:22:49.039700Z

but that's another story, let's keep it for now

pavlosmelissinos 2021-01-03T17:26:03.040Z

ok, try this out:

(and  (every?  #(get suspect %) (validators keys)) ;; key exists
      (every?  #((get validators %) (get suspect %)) (keys validators))) ;; value is valid

pavlosmelissinos 2021-01-03T17:26:31.040200Z

the syntax is really awkward (it's not how I would have done it) but it works

pavlosmelissinos 2021-01-03T17:27:12.040400Z

You can try implementing a saner alternative using merge-with or reduce-kv

pavlosmelissinos 2021-01-03T17:27:39.040600Z

merge-with is probably the most straightforward

Andrew Doolittle 2021-01-03T17:28:48.040800Z

I'm on the latest version available on melpa (20210102.631). Never experienced this before and I suspect I enabled it when typing some code while emacs was expecting a shortcut command.

Andrew Doolittle 2021-01-03T17:34:25.041Z

Just noticed I no longer have a *cider-error* buffer even after restarting emacs and my repls.

dpsutton 2021-01-03T17:35:01.041200Z

https://github.com/clojure-emacs/clojuredocs-export-edn/issues/3 is where i was following along

pavlosmelissinos 2021-01-03T17:35:16.041500Z

there's also the "dumb" version:

(defn validate
    [validators suspect]
    (and
     ((:name validators) (:name suspect))
     ((:glitter-index validators) (:glitter-index suspect))))

dpsutton 2021-01-03T17:35:27.041700Z

if you evaluate (/ 1 0) and get an error do you then have a buffer *cider-error*?

2021-01-03T17:41:15.045500Z

Not sure which channel to ask this in, but since this is such a friendly one: I've been using https://github.com/jarohen/chord and http-kit for websocket stuff for the past few years, and since it always did what it needed to do, I never bothered looking at anything else. But if I go to the latest version of http-kit, things break down, and since chord doesn't seem very active anymore, maybe it's a good time to switch. What do people use for working with websockets (frontend and backend)?

Andrew Doolittle 2021-01-03T17:41:39.045700Z

no, cider-error buffer doesn't come up. Also, M-x nrepl-log-expand-button states: Cannot open doc string file "/home/.emacs.d/elpa-26.3/cider-20200915.1827/nrepl-client.elc Looks like it's looking for the old version

dpsutton 2021-01-03T17:43:10.045900Z

strange. can you delete your CIDER version and reinstall? not sure what's going on there but if there's two versions at play it might be really weird bugs

roelof 2021-01-03T17:49:28.046100Z

thanks

roelof 2021-01-03T17:49:38.046300Z

I could even been

(defn validate
  [validators suspect]
    (every?  #((get validators %) (get suspect %)) (keys validators)))

pavlosmelissinos 2021-01-03T17:52:22.046500Z

yes that skips the first check

pavlosmelissinos 2021-01-03T17:53:17.046700Z

but it's done implicitly by the validator so in practice it's the same

roelof 2021-01-03T17:53:32.046900Z

I saw it when trying

👌 1
roelof 2021-01-03T17:54:19.047200Z

I hope I can find out how reduce can make this easier to read

pavlosmelissinos 2021-01-03T17:55:24.047400Z

merge-with and reduce-kv will not necessarily make it easier on the eye

pavlosmelissinos 2021-01-03T17:55:49.047600Z

But they will allow you to break it down into parts

roelof 2021-01-03T18:00:35.048800Z

oke, reading now the page where reduce-kv is explained

roelof 2021-01-03T18:05:27.049Z

I hope im on the right track

(defn validate2
  [validators suspect]
  (reduce-kv (fn [v s] ??? ) {} validators))
I still have to figure out what must be placed instead of the ??

pavlosmelissinos 2021-01-03T18:05:46.049200Z

the fn takes 3 params

pavlosmelissinos 2021-01-03T18:05:50.049400Z

m k and v

roelof 2021-01-03T18:06:45.049600Z

??

pavlosmelissinos 2021-01-03T18:07:08.049800Z

https://clojuredocs.org/clojure.core/reduce-kv

pavlosmelissinos 2021-01-03T18:07:11.050Z

see the examples

roelof 2021-01-03T18:07:40.050200Z

moment, you mean with k the key and with v the value

pavlosmelissinos 2021-01-03T18:07:53.050400Z

m k and v are conventions, you don't have to call them that but it helps you understand which is which

pavlosmelissinos 2021-01-03T18:07:58.050600Z

see the examples

roelof 2021-01-03T18:08:53.050800Z

yep, I have them before me if I try to make this work

roelof 2021-01-03T18:10:19.051Z

oke,

roelof 2021-01-03T18:10:26.051200Z

I have this now :

(defn validate2
  [validators suspect]
  (reduce-kv (fn [s k v]  ) {} suspect))

roelof 2021-01-03T18:16:06.051500Z

where s is the suspect , key is the key of the key I want to test and v is the validation function

pavlosmelissinos 2021-01-03T18:17:04.051700Z

you can't choose what k and v will be, they will be drawn from the last argument (suspect in your case)

roelof 2021-01-03T18:17:27.051900Z

I know I try to explain my thought process

pavlosmelissinos 2021-01-03T18:18:04.052100Z

oh ok, go on then

roelof 2021-01-03T18:18:33.052400Z

now I could check if the key exist

roelof 2021-01-03T18:18:47.052600Z

so rewrite this part: (every? #(get suspect %) (validators keys))

roelof 2021-01-03T18:19:44.052800Z

chips, stuck again

roelof 2021-01-03T18:20:50.053Z

wait a minute, if key is the key of a suspect for example the name then that is the k now

👍 1
roelof 2021-01-03T18:21:59.053300Z

so I think I can do something like this : (if #(k (vl keys) .... )

pavlosmelissinos 2021-01-03T18:26:28.054700Z

haven't tried it but sente looks like a good fit https://github.com/ptaoussanis/sente

roelof 2021-01-03T18:27:01.055100Z

nope, this is more then I can chew now

(reduce-kv (fn [vl k v] (if #(k (vl keys) #(get vl % k ) )   ) {} suspect))

roelof 2021-01-03T18:27:43.055300Z

but nested # are not allowed

roelof 2021-01-03T18:30:09.055500Z

and this looks better

roelof 2021-01-03T18:30:17.055700Z

but give a function

2021-01-03T18:34:14.055900Z

yeah, sente was around already when I chose chord. At the time I found sente was overkill

roelof 2021-01-03T18:35:45.056100Z

I need a break

roelof 2021-01-03T18:35:51.056300Z

this is given nill

roelof 2021-01-03T18:35:57.056500Z

(defn validate2
  [validators suspect]
  (reduce-kv (fn [vl k v] (if #(k (vl keys)) (#(get vl %) k) false )) {} suspect))

roelof 2021-01-03T18:36:58.056700Z

Right now I very lost on what is what

roelof 2021-01-03T18:37:23.056900Z

every? #((get validators %) (get suspect %)) (keys validators)))

roelof 2021-01-03T18:38:37.057100Z

the first part #((get validators %) will be #(get vl %)

roelof 2021-01-03T18:39:39.057300Z

and the part get suspect%) is #(k (vl keys)

roelof 2021-01-03T18:40:30.057500Z

so both would be #((get v1 %) (k (vl keys)

roelof 2021-01-03T18:42:48.057700Z

I make somewhere a big thinking error :

(defn validate2
  [validators suspect]
  (reduce-kv (fn [vl k v] (if #(k (vl keys)) #((get vl %) (k (vl keys)) false ))) {} suspect))

(defn validate-name[name]
  (print name)
  (and (string? name) (&gt; (count name) 3)))

(validate2 {:name validate-name} {:name "aaaa"})

roelof 2021-01-03T18:44:18.057900Z

still give a function so somewhere I forget a argument

roelof 2021-01-03T18:45:36.058100Z

and I do not see where

roelof 2021-01-03T19:12:40.058300Z

can you give me a hint @pavlos

roelof 2021-01-03T19:54:20.059Z

he. why here a null pointer exception

(defn validate2
  [validators suspect]
  (reduce (fn [vl s] ((get validators vl) (get suspect s ))) false (keys validators)))
 
 (defn validate-name[name]
  (print name)
  (and (string? name) (&gt; (count name) 3)))

(validate2 {:name validate-name} {:name "a"})

dpsutton 2021-01-03T19:59:25.060100Z

(Get validates vl) is called with false the first run, presumably returns nil and you invoke that

william 2021-01-03T20:03:43.061400Z

how do I do #(nth % 1) in a way that puts % in the last position so that I can use it in a -&gt;&gt; macro? (In haskell it would be something like flip nth )

roelof 2021-01-03T20:03:56.061700Z

oke, I thought the 3th argument should be the standard value

william 2021-01-03T20:05:34.061800Z

I know that I can define it myself, or I could use as-&gt; (but as-&gt; doesn't play along with debux's debug macros). Is there an idiomatic way of writing it for -&gt;&gt;?

R.A. Porter 2021-01-03T20:06:27.062Z

You can also use the -&gt; macro, but that makes it the first argument for the whole thread.

william 2021-01-03T20:07:16.062200Z

yeah, the problem is that all of the other step would like the last argument

2021-01-03T20:45:45.062400Z

it's really ugly, but you could do (#(nth % 1))

Andrew Doolittle 2021-01-03T21:22:24.062600Z

I did a complete reinstall of emacs and CIDER, but I'm still not getting a cider-error buffer. The clojuredocs error still comes up as well.