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

Merged
merged 7 commits into from Nov 8, 2015

Conversation

Projects
None yet
4 participants
@sturmer

sturmer commented Oct 18, 2015

No description provided.

sturmer added some commits Oct 17, 2015

sturmer
Start writing the exercise
The example should be working, I need to fix the tests.
sturmer
@sturmer

This comment has been minimized.

sturmer commented Oct 18, 2015

Hi everyone, I've just submitted an implementation for ETL. As usual, any comment is welcome.

@sturmer

This comment has been minimized.

sturmer commented Oct 25, 2015

Dear @yurrriq, @arguello, @bennn, when/if you have time I could use your input on this.


(test-case
"mixed case input"
(let ([actual (etl mixed-case-input)])

This comment has been minimized.

@bennn

bennn Oct 25, 2015

Contributor

Could also assert (check-equal? (hash-count actual) (hash-count expected))

This comment has been minimized.

@sturmer

sturmer Oct 26, 2015

Good idea, will do.


; TODO Provide contract on the keys and values of the input and output

(define (etl h)

This comment has been minimized.

@bennn

bennn Oct 25, 2015

Contributor

Looks good, but you can use for*/hash to build the result and in-hash to walk the old table faster.

(define (etl h)
    (for*/hash ([(score letter*) (in-hash h)]
                [letter (in-list letter*)])
      ...))

This comment has been minimized.

@sturmer

sturmer Oct 26, 2015

Those I didn't know: duly noted, thanks.

(provide (contract-out
[etl (-> hash? hash?)]))

; TODO Provide contract on the keys and values of the input and output

This comment has been minimized.

@bennn

bennn Oct 25, 2015

Contributor

Probably (hash/c exact-nonnegative-integer? (listof string?)) ..., but it'd be cool to make contracts for lowercase & uppercase letters.

This comment has been minimized.

@sturmer

sturmer Oct 26, 2015

I'll try this one, but I can't guarantee enough Racketeerism to get acceptable results :)

This comment has been minimized.

@bennn

bennn Oct 27, 2015

Contributor

:)

sturmer added some commits Oct 27, 2015

sturmer
ETL: Address comments
There is some reasoning to be done about the contract in the example,
but the code should be fine.
sturmer
Address reviews: add contracts
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.
@sturmer

This comment has been minimized.

sturmer commented Oct 28, 2015

@bennn Made some honest contracts working. What do you think?

@bennn

This comment has been minimized.

Contributor

bennn commented Oct 28, 2015

They're good!

(check-equal? (hash-ref actual k)
(hash-ref expected k))))

(test-true

This comment has been minimized.

@bennn

bennn Oct 28, 2015

Contributor

A shorter way is

(test-exn
  "test bad input: negative keys"
  exn:fail:contract?
  (lambda () (etl negative-keys input)))

This comment has been minimized.

@sturmer

sturmer Oct 28, 2015

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.

sturmer
@sturmer

This comment has been minimized.

sturmer commented Oct 29, 2015

The contract testing part is now more concise, thanks again to @bennn.

@sturmer

This comment has been minimized.

sturmer commented Nov 3, 2015

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)

This comment has been minimized.

@yurrriq

yurrriq Nov 3, 2015

Member

I might suggest deleting this line.

This comment has been minimized.

@sturmer
@yurrriq

This comment has been minimized.

Member

yurrriq commented Nov 3, 2015

After a quick once over it LGTM. Dig the contracts.

sturmer
Remove commented line
It was a leftover of debugging mode. Thanks @yurrriq for the tip.
@sturmer

This comment has been minimized.

sturmer commented Nov 3, 2015

@yurrriq Commented line removed. Thanks for digging the contracts :)

@sturmer

This comment has been minimized.

sturmer commented Nov 8, 2015

@yurrriq Lest this might escape your radar, a small reminder.

arguello added a commit that referenced this pull request Nov 8, 2015

@arguello arguello merged commit 8c1f129 into exercism:master Nov 8, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sturmer

This comment has been minimized.

sturmer commented Nov 8, 2015

Thank you @arguello!

@arguello

This comment has been minimized.

Member

arguello commented Nov 8, 2015

Thank you :)

@yurrriq

This comment has been minimized.

Member

yurrriq commented Nov 8, 2015

Thanks, guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment