How do I properly import the Twilio Java library in Clojure? - clojure

Twilio docs for Java lib
MVN for this lib
I'm trying to use Twilio from Clojure. Pretty new to Clojure dev, so I'm trying to get to grips with importing libs, in general.
My project.clj:
(defproject magical-new-project "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.0"]
;[com.twilio.sdk/twilio "7.47.5"]
[clj-twilio "0.2.0"]]
:repl-options {:init-ns magical-new-project.core})
My core.clj:
(ns magical-new-project.core
(:import [com.twilio.sdk]))
(defn foo
"I don't do a whole lot."
[x]
(println x "Fuck off, World!"))
My stack trace:
Show: Project-Only All
Hide: Clojure Java REPL Tooling Duplicates (11 frames hidden)
2. Unhandled clojure.lang.Compiler$CompilerException
Error compiling *cider-repl tutorials/magical-new-project:localhost:63188(clj)* at (1:1)
#:clojure.error{:phase :compile-syntax-check,
:line 1,
:column 1,
:source
"*cider-repl tutorials/magical-new-project:localhost:63188(clj)*"}
core.clj: 5867 clojure.core/throw-if
core.clj: 5854 clojure.core/throw-if
RestFn.java: 425 clojure.lang.RestFn/invoke
core.clj: 5988 clojure.core/load-libs
core.clj: 5969 clojure.core/load-libs
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 667 clojure.core/apply
core.clj: 6007 clojure.core/require
core.clj: 6007 clojure.core/require
RestFn.java: 421 clojure.lang.RestFn/invoke
REPL: 1 magical-new-project.core/eval6614
REPL: 1 magical-new-project.core/eval6614
Compiler.java: 7176 clojure.lang.Compiler/eval
Compiler.java: 7131 clojure.lang.Compiler/eval
core.clj: 3214 clojure.core/eval
core.clj: 3210 clojure.core/eval
main.clj: 414 clojure.main/repl/read-eval-print/fn
main.clj: 414 clojure.main/repl/read-eval-print
main.clj: 435 clojure.main/repl/fn
main.clj: 435 clojure.main/repl
main.clj: 345 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 79 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 55 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 142 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 171 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 170 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 835 java.lang.Thread/run
1. Caused by java.lang.Exception
prefix cannot be nil
core.clj: 5988 clojure.core/load-libs
core.clj: 5969 clojure.core/load-libs
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 667 clojure.core/apply
core.clj: 6007 clojure.core/require
core.clj: 6007 clojure.core/require
RestFn.java: 421 clojure.lang.RestFn/invoke
REPL: 1 magical-new-project.core/eval6614
REPL: 1 magical-new-project.core/eval6614
Compiler.java: 7176 clojure.lang.Compiler/eval
Compiler.java: 7131 clojure.lang.Compiler/eval
core.clj: 3214 clojure.core/eval
core.clj: 3210 clojure.core/eval
main.clj: 414 clojure.main/repl/read-eval-print/fn
main.clj: 414 clojure.main/repl/read-eval-print
main.clj: 435 clojure.main/repl/fn
main.clj: 435 clojure.main/repl
main.clj: 345 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 79 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 55 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 142 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 171 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 170 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 835 java.lang.Thread/run
Could someone please suggest to me what mistakes I'm making with this, and what the proper import structure should be?
Edited:
I changed my core.clj import to read:
(ns magical-new-project.core
(:import [com.twilio.http Request Response]))
and now I'm getting:
2. Unhandled clojure.lang.Compiler$CompilerException
Error compiling magical_new_project/core.clj at (1:1)
#:clojure.error{:phase :compile-syntax-check,
:line 1,
:column 1,
:source "magical_new_project/core.clj"}
Compiler.java: 7647 clojure.lang.Compiler/load
RT.java: 381 clojure.lang.RT/loadResourceScript
RT.java: 372 clojure.lang.RT/loadResourceScript
RT.java: 463 clojure.lang.RT/load
RT.java: 428 clojure.lang.RT/load
core.clj: 6126 clojure.core/load/fn
core.clj: 6125 clojure.core/load
core.clj: 6109 clojure.core/load
RestFn.java: 408 clojure.lang.RestFn/invoke
core.clj: 5908 clojure.core/load-one
core.clj: 5924 clojure.core/load-all/fn/fn
core.clj: 5924 clojure.core/load-all/fn
AFn.java: 18 clojure.lang.AFn/call
LockingTransaction.java: 273 clojure.lang.LockingTransaction/run
LockingTransaction.java: 229 clojure.lang.LockingTransaction/runInTransaction
core.clj: 5922 clojure.core/load-all
core.clj: 5916 clojure.core/load-all
core.clj: 5948 clojure.core/load-lib/fn
core.clj: 5947 clojure.core/load-lib
core.clj: 5928 clojure.core/load-lib
RestFn.java: 142 clojure.lang.RestFn/applyTo
core.clj: 667 clojure.core/apply
core.clj: 5985 clojure.core/load-libs
core.clj: 5969 clojure.core/load-libs
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 667 clojure.core/apply
core.clj: 6007 clojure.core/require
core.clj: 6007 clojure.core/require
RestFn.java: 421 clojure.lang.RestFn/invoke
REPL: 1 magical-new-project.core/eval6622
REPL: 1 magical-new-project.core/eval6622
Compiler.java: 7176 clojure.lang.Compiler/eval
Compiler.java: 7131 clojure.lang.Compiler/eval
core.clj: 3214 clojure.core/eval
core.clj: 3210 clojure.core/eval
main.clj: 414 clojure.main/repl/read-eval-print/fn
main.clj: 414 clojure.main/repl/read-eval-print
main.clj: 435 clojure.main/repl/fn
main.clj: 435 clojure.main/repl
main.clj: 345 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 79 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 55 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 142 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 171 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 170 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 835 java.lang.Thread/run
1. Caused by java.lang.ClassNotFoundException
com.twilio.http.Request
URLClassLoader.java: 436 java.net.URLClassLoader/findClass
DynamicClassLoader.java: 69 clojure.lang.DynamicClassLoader/findClass
ClassLoader.java: 588 java.lang.ClassLoader/loadClass
DynamicClassLoader.java: 77 clojure.lang.DynamicClassLoader/loadClass
ClassLoader.java: 521 java.lang.ClassLoader/loadClass
Class.java: -2 java.lang.Class/forName0
Class.java: 415 java.lang.Class/forName
RT.java: 2207 clojure.lang.RT/classForName
RT.java: 2220 clojure.lang.RT/classForNameNonLoading
core.clj: 1 magical-new-project.core/eval6626/loading--auto--
core.clj: 1 magical-new-project.core/eval6626
core.clj: 1 magical-new-project.core/eval6626
Compiler.java: 7176 clojure.lang.Compiler/eval
Compiler.java: 7165 clojure.lang.Compiler/eval
Compiler.java: 7635 clojure.lang.Compiler/load
RT.java: 381 clojure.lang.RT/loadResourceScript
RT.java: 372 clojure.lang.RT/loadResourceScript
RT.java: 463 clojure.lang.RT/load
RT.java: 428 clojure.lang.RT/load
core.clj: 6126 clojure.core/load/fn
core.clj: 6125 clojure.core/load
core.clj: 6109 clojure.core/load
RestFn.java: 408 clojure.lang.RestFn/invoke
core.clj: 5908 clojure.core/load-one
core.clj: 5924 clojure.core/load-all/fn/fn
core.clj: 5924 clojure.core/load-all/fn
AFn.java: 18 clojure.lang.AFn/call
LockingTransaction.java: 273 clojure.lang.LockingTransaction/run
LockingTransaction.java: 229 clojure.lang.LockingTransaction/runInTransaction
core.clj: 5922 clojure.core/load-all
core.clj: 5916 clojure.core/load-all
core.clj: 5948 clojure.core/load-lib/fn
core.clj: 5947 clojure.core/load-lib
core.clj: 5928 clojure.core/load-lib
RestFn.java: 142 clojure.lang.RestFn/applyTo
core.clj: 667 clojure.core/apply
core.clj: 5985 clojure.core/load-libs
core.clj: 5969 clojure.core/load-libs
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 667 clojure.core/apply
core.clj: 6007 clojure.core/require
core.clj: 6007 clojure.core/require
RestFn.java: 421 clojure.lang.RestFn/invoke
REPL: 1 magical-new-project.core/eval6622
REPL: 1 magical-new-project.core/eval6622
Compiler.java: 7176 clojure.lang.Compiler/eval
Compiler.java: 7131 clojure.lang.Compiler/eval
core.clj: 3214 clojure.core/eval
core.clj: 3210 clojure.core/eval
main.clj: 414 clojure.main/repl/read-eval-print/fn
main.clj: 414 clojure.main/repl/read-eval-print
main.clj: 435 clojure.main/repl/fn
main.clj: 435 clojure.main/repl
main.clj: 345 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 79 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 55 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 142 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 171 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 170 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 835 java.lang.Thread/run
```
Now I'm wondering if my project.clj is looking okay?
EDIT 2:
$ lein deps :tree
Retrieving clj-twilio/clj-twilio/0.2.0/clj-twilio-0.2.0.pom from clojars
Retrieving org/clojure/clojure-contrib/1.2.0/clojure-contrib-1.2.0.pom from central
Retrieving org/clojure/clojure-contrib/1.2.0/clojure-contrib-1.2.0.jar from central
Retrieving clj-twilio/clj-twilio/0.2.0/clj-twilio-0.2.0.jar from clojars
[clj-twilio "0.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
[clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
[nrepl "0.6.0" :exclusions [[org.clojure/clojure]]]
[org.clojure/clojure "1.10.0"]
[org.clojure/core.specs.alpha "0.2.44"]
[org.clojure/spec.alpha "0.2.176"]
[proto-repl "0.3.1"]
[compliment "0.2.7"]
[defprecated "0.1.3"]
[org.clojure/core.async "0.2.374"]
[org.clojure/tools.analyzer.jvm "0.6.9"]
[org.clojure/core.memoize "0.5.8"]
[org.clojure/core.cache "0.6.4"]
[org.clojure/data.priority-map "0.0.4"]
[org.clojure/tools.analyzer "0.6.7"]
[org.clojure/tools.reader "1.0.0-alpha1"]
[org.ow2.asm/asm-all "4.2"]
[org.clojure/tools.namespace "0.2.11"]
EDIT
`project.clj`
(defproject magical-new-project "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.0"]
[com.twilio.sdk/twilio "7.47.5"]]
:repl-options {:init-ns magical-new-project.core})
Stack trace:
2. Unhandled clojure.lang.Compiler$CompilerException
Error compiling *cider-repl tutorials/magical-new-project:localhost:63188(clj)* at (1:1)
#:clojure.error{:phase :compile-syntax-check,
:line 1,
:column 1,
:source
"*cider-repl tutorials/magical-new-project:localhost:63188(clj)*"}
core.clj: 5867 clojure.core/throw-if
core.clj: 5854 clojure.core/throw-if
RestFn.java: 425 clojure.lang.RestFn/invoke
core.clj: 5988 clojure.core/load-libs
core.clj: 5969 clojure.core/load-libs
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 667 clojure.core/apply
core.clj: 6007 clojure.core/require
core.clj: 6007 clojure.core/require
RestFn.java: 421 clojure.lang.RestFn/invoke
REPL: 1 magical-new-project.core/eval6648
REPL: 1 magical-new-project.core/eval6648
Compiler.java: 7176 clojure.lang.Compiler/eval
Compiler.java: 7131 clojure.lang.Compiler/eval
core.clj: 3214 clojure.core/eval
core.clj: 3210 clojure.core/eval
main.clj: 414 clojure.main/repl/read-eval-print/fn
main.clj: 414 clojure.main/repl/read-eval-print
main.clj: 435 clojure.main/repl/fn
main.clj: 435 clojure.main/repl
main.clj: 345 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 79 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 55 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 142 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 171 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 170 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 835 java.lang.Thread/run
1. Caused by java.lang.Exception
prefix cannot be nil
core.clj: 5988 clojure.core/load-libs
core.clj: 5969 clojure.core/load-libs
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 667 clojure.core/apply
core.clj: 6007 clojure.core/require
core.clj: 6007 clojure.core/require
RestFn.java: 421 clojure.lang.RestFn/invoke
REPL: 1 magical-new-project.core/eval6648
REPL: 1 magical-new-project.core/eval6648
Compiler.java: 7176 clojure.lang.Compiler/eval
Compiler.java: 7131 clojure.lang.Compiler/eval
core.clj: 3214 clojure.core/eval
core.clj: 3210 clojure.core/eval
main.clj: 414 clojure.main/repl/read-eval-print/fn
main.clj: 414 clojure.main/repl/read-eval-print
main.clj: 435 clojure.main/repl/fn
main.clj: 435 clojure.main/repl
main.clj: 345 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 79 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 55 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 142 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 171 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 170 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 835 java.lang.Thread/run
```

Related

AVX512 Vectorizing Modulo Gives Negative Result For Very Large Inputs

I am currently trying to vectorize a modulo calculation using AVX512.
Because there is no AVX modulo operation (except SVML) or an integer division, I am using the following formula d % p = d - int(float(d)/float(p))*p.
However, for very large inputs, I get negative results.
#include <bits/stdc++.h>
#include <immintrin.h>
int main() {
const auto SIZE = 1024;
int64_t input[SIZE];
int64_t output[SIZE] = {};
const auto p = 1'536; // 1.5 * 1024
std::iota(input, input + SIZE, 15596705878733779060ULL);
__m512i _divider_512 = _mm512_set1_epi64(p);
for (size_t idx = 0; idx < SIZE; idx += 8) {
__m512i _inputs = _mm512_loadu_si512(&input[idx]);
__m512i _e = _mm512_cvt_roundpd_epi64(_mm512_div_pd(_mm512_cvtepi64_pd(_inputs), _mm512_cvtepi64_pd(_divider_512)), _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC);
__m512i _mult = _mm512_mullo_epi64(_e, _divider_512);
__m512i _modulo_result = _mm512_sub_epi64(_inputs, _mult);
_mm512_storeu_si512(&output[idx], _modulo_result);
}
for (auto i = 0; i< SIZE; ++i) {
std::cout << output[i] << std::endl;
}
}
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
-255
-254
-253
-252
-251
-250
-249
-248
-247
-246
-245
-244
-243
-242
-241
-240
-239
-238
-237
-236
-235
-234
-233
-232
-231
-230
-229
-228
-227
-226
-225
-224
-223
-222
-221
-220
-219
-218
-217
-216
-215
-214
-213
-212
-211
-210
-209
-208
-207
-206
-205
-204
-203
-202
-201
-200
-199
-198
-197
-196
-195
-194
-193
-192
-191
-190
-189
-188
-187
-186
-185
-184
-183
-182
-181
-180
-179
-178
-177
-176
-175
-174
-173
-172
-171
-170
-169
-168
-167
-166
-165
-164
-163
-162
-161
-160
-159
-158
-157
-156
-155
-154
-153
-152
-151
-150
-149
-148
-147
-146
-145
-144
-143
-142
-141
-140
-139
-138
-137
-136
-135
-134
-133
-132
-131
-130
-129
-128
-127
-126
-125
-124
-123
-122
-121
-120
-119
-118
-117
-116
-115
-114
-113
-112
-111
-110
-109
-108
-107
-106
-105
-104
-103
-102
-101
-100
-99
-98
-97
-96
-95
-94
-93
-92
-91
-90
-89
-88
-87
-86
-85
-84
-83
-82
-81
-80
-79
-78
-77
-76
-75
-74
-73
-72
-71
-70
-69
-68
-67
-66
-65
-64
-63
-62
-61
-60
-59
-58
-57
-56
-55
-54
-53
-52
-51
-50
-49
-48
-47
-46
-45
-44
-43
-42
-41
-40
-39
-38
-37
-36
-35
-34
-33
-32
-31
-30
-29
-28
-27
-26
-25
-24
-23
-22
-21
-20
-19
-18
-17
-16
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
Is this a rounding error between ints and doubles? Or am I missing something else?
And how could I workaround it?

Macro expansion fails to compile even though it expands correctly?

As practice I wanted to implement some of the macros described in Doug Hoytes "Let over Lambda" which I've read a while ago.
When I started to play around with anaphoric macros I ran into a weird problem. I've implemented the alet macro described in the book as follows:
(defmacro a-let
"Anaphoric let, `this` refers to the last form in body, which should be a
function"
[bindings & body]
`(let [~'this (atom nil) ~#bindings]
(reset! ~'this ~(last body))
~#(butlast body)
(fn [& params]
(apply ~'#this params))))
This compiles fine. However, if I try to use it in code, for instance in this simple example
(a-let [a 1, b 2]
(fn [] (+ a b)))
Cider protests and throws an error with the stack trace below:
2. Unhandled clojure.lang.Compiler$CompilerException
Error compiling /home/dasbente/Dokumente/Informatik/Clojure/let-over-lambda.clj at (39:1)
Compiler.java: 6891 clojure.lang.Compiler/checkSpecs
Compiler.java: 6907 clojure.lang.Compiler/macroexpand1
Compiler.java: 6989 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6773 clojure.lang.Compiler/analyze
Compiler.java: 6729 clojure.lang.Compiler/analyze
Compiler.java: 6100 clojure.lang.Compiler$BodyExpr$Parser/parse
Compiler.java: 6420 clojure.lang.Compiler$LetExpr$Parser/parse
Compiler.java: 7003 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6773 clojure.lang.Compiler/analyze
Compiler.java: 6729 clojure.lang.Compiler/analyze
Compiler.java: 6100 clojure.lang.Compiler$BodyExpr$Parser/parse
Compiler.java: 5460 clojure.lang.Compiler$FnMethod/parse
Compiler.java: 4022 clojure.lang.Compiler$FnExpr/parse
Compiler.java: 7001 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6773 clojure.lang.Compiler/analyze
Compiler.java: 7059 clojure.lang.Compiler/eval
Compiler.java: 7025 clojure.lang.Compiler/eval
core.clj: 3206 clojure.core/eval
core.clj: 3202 clojure.core/eval
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: 87 clojure.tools.nrepl.middleware.interruptible-eval/evaluate/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: 85 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 55 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 222 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
interruptible_eval.clj: 190 clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
AFn.java: 22 clojure.lang.AFn/run
ThreadPoolExecutor.java: 1149 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 624 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 748 java.lang.Thread/run
1. Caused by clojure.lang.ExceptionInfo
Call to clojure.core/fn did not conform to spec: In: [0 1] val:
user/params fails spec: :clojure.core.specs.alpha/local-name at:
[:args :bs :arity-1 :args :varargs :form :sym] predicate:
simple-symbol? In: [0 1] val: user/params fails spec:
:clojure.core.specs.alpha/seq-binding-form at: [:args :bs :arity-1
:args :varargs :form :seq] predicate: vector? In: [0 1] val:
user/params fails spec: :clojure.core.specs.alpha/map-bindings at:
[:args :bs :arity-1 :args :varargs :form :map] predicate: coll?
In: [0 1] val: user/params fails spec:
:clojure.core.specs.alpha/map-special-binding at: [:args :bs
:arity-1 :args :varargs :form :map] predicate: map? In: [0 0] val:
& fails spec: :clojure.core.specs.alpha/arg-list at: [:args :bs
:arity-n :args] predicate: vector?
#:clojure.spec.alpha{:problems
({:path
[:args :bs :arity-1 :args :varargs :form :sym],
:pred clojure.core/simple-symbol?,
:val user/params,
:via
[:clojure.core.specs.alpha/args+body
:clojure.core.specs.alpha/arg-list
:clojure.core.specs.alpha/arg-list
:clojure.core.specs.alpha/binding-form
:clojure.core.specs.alpha/binding-form
:clojure.core.specs.alpha/local-name],
:in [0 1]}
{:path
[:args :bs :arity-1 :args :varargs :form :seq],
:pred clojure.core/vector?,
:val user/params,
:via
[:clojure.core.specs.alpha/args+body
:clojure.core.specs.alpha/arg-list
:clojure.core.specs.alpha/arg-list
:clojure.core.specs.alpha/binding-form
:clojure.core.specs.alpha/binding-form
:clojure.core.specs.alpha/seq-binding-form],
:in [0 1]}
{:path
[:args :bs :arity-1 :args :varargs :form :map],
:pred clojure.core/coll?,
:val user/params,
:via
[:clojure.core.specs.alpha/args+body
:clojure.core.specs.alpha/arg-list
:clojure.core.specs.alpha/arg-list
:clojure.core.specs.alpha/binding-form
:clojure.core.specs.alpha/binding-form
:clojure.core.specs.alpha/map-binding-form
:clojure.core.specs.alpha/map-bindings],
:in [0 1]}
{:path
[:args :bs :arity-1 :args :varargs :form :map],
:pred map?,
:val user/params,
:via
[:clojure.core.specs.alpha/args+body
:clojure.core.specs.alpha/arg-list
:clojure.core.specs.alpha/arg-list
:clojure.core.specs.alpha/binding-form
:clojure.core.specs.alpha/binding-form
:clojure.core.specs.alpha/map-binding-form
:clojure.core.specs.alpha/map-special-binding],
:in [0 1]}
{:path [:args :bs :arity-n :args],
:pred clojure.core/vector?,
:val &,
:via
[:clojure.core.specs.alpha/args+body
:clojure.core.specs.alpha/args+body
:clojure.core.specs.alpha/args+body
:clojure.core.specs.alpha/arg-list
:clojure.core.specs.alpha/arg-list],
:in [0 0]}),
:spec
#object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x3517c752 "clojure.spec.alpha$regex_spec_impl$reify__2436#3517c752"],
:value
([& user/params]
(clojure.core/apply #this user/params)),
:args
([& user/params]
(clojure.core/apply #this user/params))}
core.clj: 4739 clojure.core/ex-info
core.clj: 4739 clojure.core/ex-info
alpha.clj: 689 clojure.spec.alpha/macroexpand-check
alpha.clj: 681 clojure.spec.alpha/macroexpand-check
AFn.java: 156 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
Var.java: 702 clojure.lang.Var/applyTo
Compiler.java: 6889 clojure.lang.Compiler/checkSpecs
Compiler.java: 6907 clojure.lang.Compiler/macroexpand1
Compiler.java: 6989 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6773 clojure.lang.Compiler/analyze
Compiler.java: 6729 clojure.lang.Compiler/analyze
Compiler.java: 6100 clojure.lang.Compiler$BodyExpr$Parser/parse
Compiler.java: 6420 clojure.lang.Compiler$LetExpr$Parser/parse
Compiler.java: 7003 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6773 clojure.lang.Compiler/analyze
Compiler.java: 6729 clojure.lang.Compiler/analyze
Compiler.java: 6100 clojure.lang.Compiler$BodyExpr$Parser/parse
Compiler.java: 5460 clojure.lang.Compiler$FnMethod/parse
Compiler.java: 4022 clojure.lang.Compiler$FnExpr/parse
Compiler.java: 7001 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6773 clojure.lang.Compiler/analyze
Compiler.java: 7059 clojure.lang.Compiler/eval
Compiler.java: 7025 clojure.lang.Compiler/eval
core.clj: 3206 clojure.core/eval
core.clj: 3202 clojure.core/eval
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: 87 clojure.tools.nrepl.middleware.interruptible-eval/evaluate/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: 85 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 55 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 222 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
interruptible_eval.clj: 190 clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
AFn.java: 22 clojure.lang.AFn/run
ThreadPoolExecutor.java: 1149 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 624 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 748 java.lang.Thread/run
This is all still not really weird, mistakes happen when writing macros or something like that. However, when I expanded the macro using macroexpand-1, the resulting code made no problems whatsoever:
(macroexpand-1 '(a-let [a 1, b 2]
(fn [] (+ a b))))
;; => (clojure.core/let [this (clojure.core/atom nil) a 1 b 2]
;; (clojure.core/reset! this (fn [] (+ a b)))
;; (clojure.core/fn [& user/params] (clojure.core/apply (clojure.core/deref this) user/params)))
;; Without namespaces for readability
;; => (let [this (atom nil) a 1 b 2]
;; (reset! this (fn [] (+ a b)))
;; (fn [& params] (apply #this params)))
Which also works perfectly fine outside of macroexpand-1
(def f *) ;; => #'user/f
(f) ;; => 1
I'm not that familiar with the details of Clojures macro system so I'd be happy to be enlightened as to why this weird behaviour occurs because I am pretty lost on this one.
Thanks in advance!
I'm not sure where that mess of an error message came from. I can't say I've ever seen an error like that before.
When I run it, I get:
CompilerException java.lang.RuntimeException: Can't use qualified name as parameter: mandelbrot-redo.seesaw-main.first-main/params, compiling:(C:\Users\slomi\AppData\Local\Temp\form-init395175488607706237.clj:1:1)
Then the error is obvious. When creating bindings inside of a ` quoted form, they're automatically namespaced to the current namespace. Function parameters can't be namespaced however, as the error says.
Change the last bit to:
(fn [& params#]
(apply ~'#this params#))))
Note the #. Those turn params into a unique, non-namespaced symbol.
Now, it appears to work fine:
(a-let [a 1, b 2]
(fn [] (+ a b)))
=>
#object[mandelbrot_redo.seesaw_main.first_main$eval8162$fn__8165
0x63cf5b7e
"mandelbrot_redo.seesaw_main.first_main$eval8162$fn__8165#63cf5b7e"]
You can also use a promise instead of an atom. It's a little neater, and more correct, since you only want to set it once:
(defmacro my-a-let
"Anaphoric let, `this` refers to the last form in body, which should be a function"
[bindings & body]
`(let [~'this (promise)
~#bindings]
(deliver ~'this ~(last body))
~#(butlast body)
(fn [& params#]
(apply ~'#this params#))))

trouble displaying type that implements IPersistentMap interface

I am implementing a type that is really just a wrapper for hash-maps
(defn as-pairs [m]
(when-not (empty? m)
(seq (persistent! (reduce (fn [s [k vs]]
(reduce (fn [s v] (conj! s [k v])) s vs)) (transient []) m)))))
(deftype Rel [m]
clojure.lang.Seqable
(seq [this] (as-pairs m))
clojure.lang.ILookup
(valAt [this k] (get m k))
(valAt [this k default] (get m k default))
clojure.lang.IPersistentMap
(assoc [this k v] (Rel. (update m k #(conj (or % #{}) v))))
(assocEx [this k v] (throw (Exception.)))
(without [this k] (Rel. (dissoc m k))))
(defn relation [] (Rel. (hash-map)))
It seems to be working as expected
state-machines.maps> (def r (relation))
#'state-machines.maps/r
state-machines.maps> (type r)
state_machines.maps.Rel
state-machines.maps> r
{} ; interesting that it actually displays a map! -- source of problem?
state-machines.maps> (type (assoc r :foo 1 :foo 2 :bar 1))
state_machines.maps.Rel
state-machines.maps> (get (assoc r :foo 1 :foo 2 :bar 1) :foo)
#{1 2}
state-machines.maps> (seq (assoc r :foo 1 :foo 2 :bar 1))
([:foo 1] [:foo 2] [:bar 1])
state-machines.maps> (assoc r :foo 1 :foo 2 :bar 1)
ClassCastException clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry clojure.core/key (core.clj:1518)
state-machines.maps>
looking at the stack trace
1. Unhandled java.lang.ClassCastException
clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry
core.clj: 1518 clojure.core/key
core_print.clj: 212 clojure.core/print-map/fn
core_print.clj: 59 clojure.core/print-sequential
core_print.clj: 208 clojure.core/print-map
core_print.clj: 217 clojure.core/fn
core_print.clj: 217 clojure.core/fn
MultiFn.java: 233 clojure.lang.MultiFn/invoke
pr_values.clj: 35 clojure.tools.nrepl.middleware.pr-values/pr-values/fn/reify
interruptible_eval.clj: 113 clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn/fn
main.clj: 241 clojure.main/repl/read-eval-print
main.clj: 258 clojure.main/repl/fn
main.clj: 258 clojure.main/repl
main.clj: 174 clojure.main/repl
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 646 clojure.core/apply
core.clj: 641 clojure.core/apply
regrow.clj: 18 refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 87 clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 646 clojure.core/apply
core.clj: 1881 clojure.core/with-bindings*
core.clj: 1881 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
interruptible_eval.clj: 85 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 55 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 222 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
interruptible_eval.clj: 190 clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
AFn.java: 22 clojure.lang.AFn/run
ThreadPoolExecutor.java: 1142 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 617 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 745 java.lang.Thread/run
I am assuming that something is happening in one of
core_print.clj: 212 clojure.core/print-map/fn
core_print.clj: 59 clojure.core/print-sequential
core_print.clj: 208 clojure.core/print-map
Is this an interface that I need to implement?
After updating as-pairs to
(defn as-pairs [m]
(when-not (empty? m)
(seq (persistent! (reduce (fn [s [k vs]]
(reduce (fn [s v] (conj! s (clojure.lang.MapEntry/create k v))) s vs)) (transient []) m)))))
the result is:
state-machines.maps> (assoc (relation) :foo 1 :foo 2 :bar 1)
{:foo 1, :foo 2, :bar 1}
As you suspect, the error is arising in print-map, which calls seq on its argument and then calls key and val on each element of that sequence. As the error message states, these two functions expect their argument to conform to the java.util.Map$Entry interface, and Clojure vectors do not conform to that interface.
The solution is to take the [k v] in your as-pairs function and replace it with an expression that creates a map entry; see this question for details.

c++ Multiples of 5 in sieve of atkin implemenation

I'm solving a problem over at project euler which requires me to find the sum of all primes under 2 million. I tried to implement sieve of atkin and strangely it sets numbers like 65,85 as primes. I looked at the code and algorithm for over a a day but can't find anything wrong. I'm sure it must be something silly but i can't find it. Thanks in advance
i'm using visual studio express 2012.
here's the code:
#include "stdafx.h"
#include <iostream>
#include <math.h>
#include <vector>
#include <fstream>
#include <conio.h>
int main(){
long long int limit,n;
std::cout<<"Enter a number...."<<std::endl;
std::cin>>limit;
std::vector<bool> prime;
for(long long int k=0;k<limit;k++){ //sets all entries in the vector 'prime' to false
prime.push_back(false);
}
long long int root_limit= ceil(sqrt(limit));
//sive of atkin implementation
for(long long int x=1;x<=root_limit;x++){
for(long long int y=1;y<=root_limit;y++){
n=(4*x*x)+(y*y);
if(n<=limit && (n%12==1 || n%12==5)){
prime[n]=true;
}
n=(3*x*x)+(y*y);
if(n<=limit && n%12==7){
prime[n]=true;
}
n=(3*x*x)-(y*y);
if(x>y && n<=limit && n%12==11){
prime[n]=true;
}
}
}
//loop to eliminate squares of the primes(making them square free)
for(long long int i=5;i<=root_limit;i++){
if(prime[i]==true){
for(long long int j=i*i;j<limit;j+=(i*i)){
prime[j]=false;
}
}
}
unsigned long long int sum=0;
//print values to a seperate text file
std::ofstream outputfile("data.txt");
outputfile<<"2"<<std::endl;
outputfile<<"3"<<std::endl;
for(long long int l=5;l<limit;l++){
if(prime[l]==true){
sum+=l;
outputfile<<l<<std::endl;;
}
}
outputfile.close();
std::cout<<"The sum is...."<<sum+5<<std::endl;
prime.clear();
return 0;
}
and hers the data.txt i pointed out few errors
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
65<-----
67
71
73
79
83
85<-----
89
91
97
101
103
107
109
113
127
131
137
139
143
145<----
149
151
157
163
167
173
179
181
185<----
191
193
197
199
205
211
221
223
227
229
233
239
241
247
251
257
259
263
265
269
271
277
281
283
293
299
305
307
311
313
317
331
337
347
349
353
359
365
367
373
377
379
383
389
397
401
403
407
409
419
421
427
431
433
439
443
445
449
457
461
463
467
479
481
485
487
491
493
499
503
505
509
511
521
523
533
541
545
547
557
559
563
565
569
571
577
587
593
599
601
607
611
613
617
619
629
631
641
643
647
653
659
661
671
673
677
679
683
685
689
691
697
701
703
709
719
727
733
739
743
745
751
757
761
763
767
769
773
785
787
793
797
803
809
811
821
823
827
829
839
851
853
857
859
863
865
871
877
881
883
887
901
905
907
911
919
923
929
937
941
947
949
953
965
967
971
977
983
985
991
997
1009
1013
1019
1021
1027
1031
1033
1037
1039
1049
1051
1061
1063
1067
1069
1073
1079
1087
1091
1093
1097
1099
1103
1105
1109
1117
1123
1129
1145
1147
1151
1153
1157
1159
1163
1165
1171
1181
1187
1189
1193
1199
1201
1205
1213
1217
1223
1229
1231
1237
1241
1249
1259
1261
1267
1277
1279
1283
1285
1289
1291
1297
1301
1303
1307
1313
1319
1321
1327
1339
1345
1351
1361
1367
1373
1381
1385
1387
1391
1399
1403
1405
1409
1417
1423
1427
1429
1433
1439
1447
1451
1453
1459
1465
1469
1471
1481
1483
1487
1489
1493
1499
1511
1513
1517
1523
1531
1537
1543
1549
1553
1559
1565
1567
1571
1579
1583
1585
1591
1597
1601
1603
1607
1609
1613
1619
1621
1627
1637
1649
1651
1657
1663
1667
1669
1679
1685
1687
1693
1697
1699
1703
1709
1717
1721
1723
1727
1733
1739
1741
1745
1747
1753
1759
1765
1769
1777
1781
1783
1787
1789
1801
1807
1811
1823
1831
1843
1847
1853
1861
1865
1867
1871
1873
1877
1879
1885
1889
1891
1901
1907
1913
1921
1931
1933
1937
1939
1945
1949
1951
1961
1963
1973
1979
1985
1987
1991
1993
1997
1999
You're supposed to flip the entries to the sieve list. In the first nested for loops instead of prime[n]=true; you should have prime[n]=!prime[n];

Clojure Docs: Understanding This Example of the Reduce Function

Reading through the Clojure docs and I'm confused by one example of the reduce function. I understand what reduce does, but there's a lot going on in this example and I'm not sure how it's all working together.
(reduce
(fn [primes number]
(if (some zero? (map (partial mod number) primes))
primes
(conj primes number)))
[2]
(take 1000 (iterate inc 3)))
=> [2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997]
From what I understand, reduce takes a function, in this case an anonymous function. That function takes two arguments, a collection and a number. Then we have a conditional statement that checks if the number zero appears in the collection.
(map (partial mod number) primes) confuses me. Doesn't mod take two arguments and return the remainder of dividing the first by the second?
It appears that if this conditional returns true, it returns the collection of primes. If not, add the number to the collection of primes. Is that correct?
And the final line, it's a collection of 1,000 numbers starting at 3. Would someone be able to walk through this function?
You probably already know this but the first thing to note is the following property: A number is prime if it is indivisible by any prime number smaller than it.
So the anonymous function starts with a vector of previous primes, and then checks if number is divisible by any of the previous primes. If it is divisible by any of the previous primes, it will just pass on the vector of previous primes, otherwise it will add the current number to the vector of primes and then return the new vector.
(partial mod number) is equivalent to (fn [x] (mod number x)) in this case.
To step through a few cases:
;Give a name to the anonymous function
(defn prime-checker [primes number]
(if (some zero? (map (partial mod number) primes))
primes
(conj primes number)))
;This is how reduce will call the anonymous function
(prime-checker [2] 3)
-> ((map (partial mod number) primes) = [1]
-> will return [2 3]
(prime-checker [2 3] 4)
-> ((map (partial mod number) primes) = [0 1]
-> some zero? finds a zero value here so the function will return [2 3]
(prime-checker [2 3] 5)
-> ((map (partial mod number) primes) = [1 2]
-> will return [2 3 5]
Hopefully you can see from this how reduce with this function returns a list of primes.