pradipbn
2019-2-17 08:20:18

@pradipbn has joined the channel


contact
2019-2-17 14:15:58

Hello!


contact
2019-2-17 14:16:24

How do I make raco test run tests in a package test/ folder and only there?


contact
2019-2-17 14:16:27

Thanks!


bkovitz
2019-2-17 14:49:23

@contact I’m not sure of the best way, but one way is raco test test/*.rkt.


contact
2019-2-17 14:51:20

is there something like npm test where npm test essentially runs a few bash scripts like tape **/*.js \| tap-spec


bkovitz
2019-2-17 14:52:49

@contact I haven’t heard of such a thing, but I’m only a beginner myself. What doesn’t raco test test/*.rkt do that you need?


contact
2019-2-17 14:54:09

imagine you send the message test to the package and then it does its things… you don’t have to remember one way for each package.


contact
2019-2-17 14:54:56

so, whatever the package, you just say: $ cd pkg; raco test


bkovitz
2019-2-17 14:57:38

There may be a more Rackety way to do it, but what I do is make a Makefile. In each directory, you have a Makefile with a target called test, like this. Then you can do $ cd pkg; make test in each directory.


contact
2019-2-17 14:58:35

ok! thank you very much :slightly_smiling_face:


bkovitz
2019-2-17 14:59:23

:smile: Actually, maybe this is the Rackety way to do it: it’s using a very simple DSL that perfectly fits what you’re trying to do.


bkovitz
2019-2-17 15:00:19

BTW, have you used Makefiles before? Specifically, do you know that the line with raco test *.rkt must start with a tab?


greg
2019-2-17 15:40:31

If a package is installed you can raco test -p <package-name>.


contact
2019-2-17 16:21:56

@bkovitz yes! I would rather avoid any external tool as much as possible… @greg $ raco test package/ seems to work good enough :slightly_smiling_face:


abbyrjones72
2019-2-17 17:49:51

Working on a problem from a textbook I found online. “define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers”

I have this so far, but not all situations are correct.

(define (sum-of-squares x y z) (cond ((> x y z) (+ (* x x) (* y y))) ((< x y) (> x z) (> y z) (+ (* x x) (* y y))) ((< x y z) (+ (* y y) (* z z))) (else (+ (* x x) (* z z))))) (sum-of-squares 4 5 6) (sum-of-squares 4 6 5) (sum-of-squares 29 14 27) (sum-of-squares 3 4 1) (sum-of-squares 27 14 29)


abbyrjones72
2019-2-17 17:50:15

the second method fails


soegaard2
2019-2-17 17:50:50

It’s possible to solve the problem using your method.


soegaard2
2019-2-17 17:51:06

But it is hard to see if all cases have been accounted for.


soegaard2
2019-2-17 17:51:48

An alternative is to sum all squares and subtract the square of the smallest number.


soegaard2
2019-2-17 17:52:20

If you have a helper called min that computes the smallest number of three inputs,


soegaard2
2019-2-17 17:52:24

then you can write:


soegaard2
2019-2-17 17:52:58

(- (+ (square x) (square y) (square z)) (square (min x y z)))


abbyrjones72
2019-2-17 17:53:14

ah that sounds like a good plan


abbyrjones72
2019-2-17 17:53:16

let me try that


soegaard2
2019-2-17 17:54:29

Btw - in the line ((&lt; x y) (&gt; x z) (&gt; y z) (+ ( *x x) (* y y))) I think you forgot an and: ((and (&lt; x y) (&gt; x z) (&gt; y z)) (+ ( *x x) (* y y)))


abbyrjones72
2019-2-17 17:57:34

I’m not sure I am logical enough to be a programmer, to be honest. I’ve been trying unsuccessfully for years with only frustration. I like LISP because it’s fun and very different that what I’ve seen, but I might just go back to writing lol.


soegaard2
2019-2-17 17:58:01

For the record - that problem is notorious.


soegaard2
2019-2-17 17:58:17

Countless people gets stuck on that one.


bkovitz
2019-2-17 18:34:09

@abbyrjones72 I hope you’ll be patient with yourself. Most of programming is getting accustomed to certain ways of mentally framing things so that good ideas usually come to mind quickly. In that respect, it’s just like playing a musical instrument, cooking, writing, and every other skill. I was a commercial programmer for about 15 years, very good at coming up with object-oriented and imperative ways of making programs. I’m now learning Racket and finding it pretty slow going even though understanding the semantics of the language is pretty easy. I’m just not accustomed to how things are done in Racket. I often have to go through several clumsy versions of even fairly elementary things before I find a way to make the program that’s simple and not error-prone.


sorawee
2019-2-17 19:09:22

How does with-handlers break @greg’s convention?


abbyrjones72
2019-2-17 21:31:37

@soegaard2 this problem is really an issue? Well I don’t feel so bad now.


soegaard2
2019-2-17 21:33:42

@abbyrjones72 Oh yes. It’s much harder than it looks. And since it is in SICP it has been discussed here multiple times.


abbyrjones72
2019-2-17 21:34:12

I’ll look into the helper method for sure


notjack
2019-2-17 21:56:39

Note that raco test -p package works no matter what your current directory is, and it’s what the package catalog build server does for all packages


oldsin
2019-2-18 01:39:24

Anyone know if there is a way to use my own error report procedures if I parse use brag (My parser knowledge is only limited within the book beautiful racket, brag suit my needs but I believe I can provide better error report)? Or maybe you guys can recommend me a parser framework which provides facilities for better parse error report? I’m trying to parse a very simple language that can be written in CFG. Appreciate any help!

(P.S. My statement is not very clear about ‘better parse error report’, an example would be: - not so good one: Encountered parsing error near … - better one: only … can be written after …)