notjack
2021-2-13 08:52:23

is bound-identifier=? transitive?


notjack
2021-2-13 08:52:36

I’ve been assuming so but just wanted to double check


ryanc
2021-2-13 09:08:03

Yes.


gknauth
2021-2-13 15:47:08

Am I doing something wrong? Trying Racket CS 8.0.0.5, both of these variants fail with the same error. (let* ([expected 968900] [epsilon (* .003 expected)]) (check-= (haversine-gcdist-meters ll1 ll2) expected epsilon)) (define v1 (haversine-gcdist-meters ll1 ll2)) (define v2 968900) (define epsilon (* v2 0.003)) (check-= v1 v2 epsilon) ../../../../Applications/Racket/Racket-v8.0.0.5/share/pkgs/rackunit-lib/rackunit/private/check.rkt:116:13: check-=: arity mismatch; the expected number of arguments does not match the given number given: 2


soegaard2
2021-2-13 15:52:27

Is this with the teaching languages or plain racket? (I notice, that the teaching languages use a check-within. ) In plain Racket, I’d expect your (check-= v1 v2 epsilon) to work.


gknauth
2021-2-13 15:52:44

lang racket


laurent.orseau
2021-2-13 15:55:16

look at the source of check-= maybe?


laurent.orseau
2021-2-13 15:55:27

(on your machine)


gknauth
2021-2-13 15:55:51

laurent.orseau
2021-2-13 15:56:45

hahahah, well that’s obvious, isn’t it? :smile:


sorawee
2021-2-13 15:56:54

What if you try #lang racket (require rackunit) (check-= 1 2 3) ?


gknauth
2021-2-13 15:57:55

That works (i.e., no output, no error).


gknauth
2021-2-13 15:58:40

My checks are within (module+ test … ) and the (require rackunit) is at the top, in the broken version.


laurent.orseau
2021-2-13 15:59:30

maybe you require something that shadows it? (though normally that should be an error)


laurent.orseau
2021-2-13 15:59:50

well, no, the error does point to rackunit


gknauth
2021-2-13 16:00:18

also (require rackunit) is the only require


laurent.orseau
2021-2-13 16:00:27

Buy another computer.


sorawee
2021-2-13 16:00:35

Well, it might be a rackunit extension


sorawee
2021-2-13 16:00:57

So the fact that it points to rackunit doesn’t rule out that it might be shadowed


sorawee
2021-2-13 16:01:21

But if rackunit is the only require, then that’s unlikely


sorawee
2021-2-13 16:02:41

How difficult is it to post the whole source file here?


sorawee
2021-2-13 16:02:49

(that has the problem)


gknauth
2021-2-13 16:03:00

#lang racket (require rackunit) ; for formulae, see: ; <https://www.movable-type.co.uk/scripts/latlong.html> ; variation: west is -, east is + (define (true-&gt;magnetic true-course variation) (keep360 (- true-course (limit-plus-minus variation 90)))) (define (magnetic-&gt;true magnetic-course variation) (keep360 (+ magnetic-course (limit-plus-minus variation 90)))) (define (keep360 n) (let loop ([x n]) (cond [(&lt; x 0) (loop (+ x 360))] [(&gt; x 360) (loop (- x 360))] [else x]))) (define (limit-plus-minus n m) (if (and (&gt;= n (- m)) (&lt;= n m)) n (error (format "limit-plus-minus (-~a &lt;= ~a &lt;= ~a) not true" m n m)))) (define (dms-&gt;deg degrees minutes seconds nsew) (let* ([d (+ (abs degrees) (/ minutes 60) (/ seconds 3600))]) (cond [(eq? nsew 'S) (limit-plus-minus (- d) 90)] [(eq? nsew 'W) (limit-plus-minus (- d) 180)] [(eq? nsew 'N) (limit-plus-minus d 90)] [(eq? nsew 'E) (limit-plus-minus d 180)] [else (error (format "dms-&gt;deg: nsew must be in {'N 'S 'E 'W}, given ~a"))]))) (define (dm-&gt;deg degrees minutes nsew) (dms-&gt;deg degrees minutes 0 nsew)) (struct latlon (lat lon) #:transparent) ;(define pi 3.14159265359) (define ratio-π-180 (/ pi 180)) (define ratio-180-π (/ 180 pi)) (define meters-per-nautical-mile 1852) (define (haversine-gcdist-meters latlon1 latlon2) (let* ([R 6371009] ; WGS84 ellipsoid radius in meters [φ1 (* (latlon-lat latlon1) ratio-π-180)] [φ2 (* (latlon-lat latlon2) ratio-π-180)] [λ1 (* (latlon-lon latlon1) ratio-π-180)] [λ2 (* (latlon-lon latlon2) ratio-π-180)] [Δφ (- φ2 φ1)] [Δλ (- λ2 λ1)] [sin-Δφ/2 (sin (/ Δφ 2))] [sin-Δλ/2 (sin (/ Δλ 2))] [a (+ (* sin-Δφ/2 sin-Δφ/2) (* (cos φ1) (cos φ2) sin-Δλ/2 sin-Δλ/2))] [c (* 2 (atan (sqrt a) (- 1 a)))]) (* R c))) (define (bearing latlon1 latlon2) (let* ([φ1 (* (latlon-lat latlon1) ratio-π-180)] [φ2 (* (latlon-lat latlon2) ratio-π-180)] [λ1 (* (latlon-lon latlon1) ratio-π-180)] [λ2 (* (latlon-lon latlon2) ratio-π-180)] [Δλ (- λ2 λ1)] [y (* (sin Δλ) (cos φ2))] [x (- (* (cos φ1) (sin φ2)) (* (sin φ1) (cos φ2) (cos Δλ)))] [θ (atan y x)]) (keep360 (+ (* θ ratio-180-π) 360)))) (module+ test (define ll1 (latlon (dms-&gt;deg 50 3 59 'N) (dms-&gt;deg 5 42 53 'W))) (define ll2 (latlon (dms-&gt;deg 58 38 38 'N) (dms-&gt;deg 3 4 12 'W))) (define pa1 (latlon (dms-&gt;deg 40 0 0 'N) (dms-&gt;deg 77 0 0 'W))) (define pa2 (latlon (dms-&gt;deg 41 0 0 'N) (dms-&gt;deg 77 0 0 'W))) (define pa3 (latlon (dms-&gt;deg 40 0 0 'N) (dms-&gt;deg 78 0 0 'W))) (let* ([expected 968900] [epsilon (* .003 expected)]) (check-= (haversine-gcdist-meters ll1 ll2) expected epsilon)) (define v1 (haversine-gcdist-meters ll1 ll2)) (define v2 968900) (define epsilon (* v2 0.003)) (check-= v1 v2 epsilon) (check-= (bearing ll1 ll2) 0) (check-= (haversine-gcdist-meters pa1 pa2) (* 60 meters-per-nautical-mile)) (check-= (haversine-gcdist-meters pa1 pa3) (* 60 .7 meters-per-nautical-mile)) (check-eq? (keep360 5) 5) (check-eq? (keep360 365) 5) (check-eq? (keep360 -5) 355) (check-eq? (true-&gt;magnetic 0 -11) 11) (check-eq? (true-&gt;magnetic 360 -11) 11) (check-eq? (magnetic-&gt;true 0 -11) 349) (check-eq? (magnetic-&gt;true 244 -11) 233) (check-eq? (magnetic-&gt;true 310 -11) 299) (check-eq? (limit-plus-minus -90 90) -90) (check-eq? (limit-plus-minus -89 90) -89) (check-eq? (limit-plus-minus 0 90) 0) (check-eq? (limit-plus-minus 89 90) 89) (check-eq? (limit-plus-minus 90 90) 90) (check-exn exn:fail? (lambda () (limit-plus-minus 91 90) 90)) (check-exn exn:fail? (lambda () (limit-plus-minus -91 90) 90)) )


sorawee
2021-2-13 16:03:18

OK!


sorawee
2021-2-13 16:03:23

I can reproduce the problem!


sorawee
2021-2-13 16:04:40

This line:

(check-= (bearing ll1 ll2) 0)


sorawee
2021-2-13 16:04:46

provides only two arguments


gknauth
2021-2-13 16:05:15

Oh duh! Thanks! I’m an idiot. Much appreciated. I return you to your normal Saturday.


qyrzto1nq
2021-2-13 16:51:57

@qyrzto1nq has joined the channel


soegaard2
2021-2-13 20:25:43

My macro tutorial now has a section 6 “Constructing syntax objects from templates”. Feedback is welcome: Contents, grammar etc.

I also need some suggestions for exercises.


me1890
2021-2-13 23:16:37

How can i measure the time it takes to expand my program?


me1890
2021-2-13 23:20:21

I think the macro expander is taking a long time on my program, but i’m not certain


sorawee
2021-2-13 23:39:06

Here’s one possibility: time raco make yourfile.rkt


yilin.wei10
2021-2-14 01:07:02

Would it be possible if I try my hand at extending the arrow type to support the DepFun use-case?


samth
2021-2-14 01:27:54

Yes certainly!


samth
2021-2-14 01:28:42

Feel free to start a PR and ask questions, or to ask here — @capfredf @ben and I are the ones around who know the internals best


me1890
2021-2-14 02:11:42

that showed pretty good times, so it seems like something else is really slowing down my racket script


jestarray
2021-2-14 02:37:08

congratz on 8.0 release racket team :party:


samth
2021-2-14 03:30:40

I recommend raco profile yourscript.rkt


me1890
2021-2-14 03:31:24

i will try that thanks


me1890
2021-2-14 03:31:50

I think my issue might have something to do with drracket, because it’s much faster when i run my script from the terminal vs in drracket


me1890
2021-2-14 03:32:46

i was abusing some macros, so I figured it might have been the macro expander


raoul.schorer
2021-2-14 03:36:09

Did you disable debug mode in DrRacket? It’s enabled by default, I think.


raoul.schorer
2021-2-14 03:36:39

Which is not the case when running from the command line.


me1890
2021-2-14 03:39:14

How do i disable debug mode?


me1890
2021-2-14 03:39:36

I timed my script and it seemed to run quick, but it was taking upwards of 10 seconds to start


raoul.schorer
2021-2-14 03:44:50

Well, it must compile first, that’s why it takes time to start


raoul.schorer
2021-2-14 03:45:21

if you want to AOT compile, ‘raco make myfile.rkt’ on the command line.


me1890
2021-2-14 03:50:38

yeah, i just thought that the compilation was taking a very long time.


me1890
2021-2-14 03:52:26

I’ve changed my code do use less innefficient macros, and it’s down to compiling in 3.5s


me1890
2021-2-14 03:52:48

but when clicking the “run” button in drracket,it takes about 20 seconds to compile


raoul.schorer
2021-2-14 03:55:56

Yes, I seem to remember there was something with debug mode in DrRacket but I can’t find it anymore


raoul.schorer
2021-2-14 03:56:09

sorry


me1890
2021-2-14 03:56:17

okay


me1890
2021-2-14 03:56:28

I can compile on command line