-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Adds Concept Exercise Squeaky Clean #611
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
I suspect that it's because your test file is not structured the way it's supposed to be, and the code extractor in the test runner fails on that. It's poorly/not al all documented, but try and copy the structure of another concept exercise test file. |
The tests are flaky for some reason we haven't figured out yet (there is an open isue for it), I tried running them again, but they are still failing, and on these new tests specifically. I'll take a look at the tests when I have time, but I think Jie is right, there is probably some requirement in the test runner that isn't met. |
I ran the exercise with the test-runner locally and the error message is "Number of tests doesn't match number of extracted code snippets" |
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.
Thank you for the nice exercise, I hope that 2 reviews are not too much at once :D
Only for reference, here is my solution, I wrote after only looking at the instructions.
module SqueakyClean exposing (clean1, clean2, clean3, clean4, clean5)
clean1 : String -> String
clean1 =
String.replace " " "_"
clean2 : String -> String
clean2 str =
List.foldl (\ctrl -> String.replace ctrl "[CTRL]") (clean1 str) [ "\n", "\u{000D}", "\t" ]
clean3 : String -> String
clean3 str =
case String.split "-" (clean2 str) of
[] ->
""
first :: rest ->
String.concat (first :: List.map capitalize rest)
capitalize : String -> String
capitalize str =
case String.uncons str of
Nothing ->
str
Just ( first, rest ) ->
String.fromChar (Char.toUpper first) ++ rest
clean4 : String -> String
clean4 =
clean3 >> String.filter (Char.isDigit >> not)
clean5 : String -> String
clean5 =
let
notGreek c =
Char.toCode c < Char.toCode 'α' || Char.toCode 'ω' < Char.toCode c
notEmoticon c =
Char.toCode c < 128512 || 128591 < Char.toCode c
in
clean4 >> String.filter notGreek >> String.filter notEmoticon
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.
Very cool, it's taking shape :)
I left a few more comments
Hi Pete, I'm on holiday at the moment, but it looks like you and Joe have everything in hand, so I'll leave it to you two :) |
Another thing, could you add a
This file is meant to work with configlet. When running |
Incorporated all comments. Thanks for the feedback. |
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.
Two more tiny little things! After that I'm merging :D
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.
Perfect!
Thank you so much for making this, I know how much work making concepts and concepts exercisess is, it will mean a lot to the students.
Concept Exercise Squeaky Clean for Strings concept.
Answers #606.
Concepts
Char
: know of the existence of thechar
type; know that achar
represents; know how to define achar
; know how to access achar
in a string; know of some basicchar
methods (like converting to uppercase).String
: know how to use a strings.Prerequisites