-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement etl #27
Implement etl #27
Conversation
The example should be working, I need to fix the tests.
Hi everyone, I've just submitted an implementation for ETL. As usual, any comment is welcome. |
|
||
(test-case | ||
"mixed case input" | ||
(let ([actual (etl mixed-case-input)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also assert (check-equal? (hash-count actual) (hash-count expected))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, will do.
There is some reasoning to be done about the contract in the example, but the code should be fine.
The input is now checked in tests. To check the output, one can just change the last line of the example implementation by removing the application of the function string-downcase to see the contract failing spectacularly.
@bennn Made some honest contracts working. What do you think? |
They're good! |
(check-equal? (hash-ref actual k) | ||
(hash-ref expected k)))) | ||
|
||
(test-true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A shorter way is
(test-exn
"test bad input: negative keys"
exn:fail:contract?
(lambda () (etl negative-keys input)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comments @bennn. That would also get rid of the (lambda _ #t)
which I didn't love --- I'll admit it. I am going to make those changes tomorrow.
The contract testing part is now more concise, thanks again to @bennn. |
If this is considered good, could anyone please merge it? I think @arguello was so kind to do it last time? Please let me know if there is anything else I can do on my side. |
(define (etl h) | ||
(for*/hash ([(score letter*) (in-hash h)] | ||
[letter (in-list letter*)]) | ||
;(printf "~a: ~a\n" letter score) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might suggest deleting this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved!
After a quick once over it LGTM. Dig the contracts. |
It was a leftover of debugging mode. Thanks @yurrriq for the tip.
@yurrriq Commented line removed. Thanks for digging the contracts :) |
@yurrriq Lest this might escape your radar, a small reminder. |
Thank you @arguello! |
Thank you :) |
Thanks, guys. |
No description provided.