
is bound-identifier=?
transitive?

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

Yes.

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

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.

lang racket

look at the source of check-= maybe?

(on your machine)


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

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

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

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

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

well, no, the error does point to rackunit

also (require rackunit) is the only require

Buy another computer.

Well, it might be a rackunit extension

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

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

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

(that has the problem)

#lang racket
(require rackunit)
; for formulae, see:
; <https://www.movable-type.co.uk/scripts/latlong.html>
; variation: west is -, east is +
(define (true->magnetic true-course variation)
(keep360 (- true-course (limit-plus-minus variation 90))))
(define (magnetic->true magnetic-course variation)
(keep360 (+ magnetic-course (limit-plus-minus variation 90))))
(define (keep360 n)
(let loop ([x n])
(cond [(< x 0) (loop (+ x 360))]
[(> x 360) (loop (- x 360))]
[else x])))
(define (limit-plus-minus n m)
(if (and (>= n (- m)) (<= n m))
n
(error (format "limit-plus-minus (-~a <= ~a <= ~a) not true" m n m))))
(define (dms->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->deg: nsew must be in {'N 'S 'E 'W}, given ~a"))])))
(define (dm->deg degrees minutes nsew)
(dms->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->deg 50 3 59 'N) (dms->deg 5 42 53 'W)))
(define ll2 (latlon (dms->deg 58 38 38 'N) (dms->deg 3 4 12 'W)))
(define pa1 (latlon (dms->deg 40 0 0 'N) (dms->deg 77 0 0 'W)))
(define pa2 (latlon (dms->deg 41 0 0 'N) (dms->deg 77 0 0 'W)))
(define pa3 (latlon (dms->deg 40 0 0 'N) (dms->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->magnetic 0 -11) 11)
(check-eq? (true->magnetic 360 -11) 11)
(check-eq? (magnetic->true 0 -11) 349)
(check-eq? (magnetic->true 244 -11) 233)
(check-eq? (magnetic->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))
)

OK!

I can reproduce the problem!

This line:
(check-= (bearing ll1 ll2) 0)

provides only two arguments

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

@qyrzto1nq has joined the channel

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.

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

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

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

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

Yes certainly!

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

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

congratz on 8.0 release racket team :party:

I recommend raco profile yourscript.rkt

i will try that thanks

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

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

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

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

How do i disable debug mode?

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

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

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

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

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

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

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

sorry

okay

I can compile on command line