Skip to content
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

Lab1: Exercise 8 #1

Open
BertLisser opened this issue Sep 14, 2017 · 1 comment
Open

Lab1: Exercise 8 #1

BertLisser opened this issue Sep 14, 2017 · 1 comment

Comments

@BertLisser
Copy link

The remark if the puzzle is wel-designed is not an assumption.
So the function guilty must return a list of boys.
A proposal to rewrite the code is:

evaluateAll :: [Boy] -> [[Bool]] -> [(Boy, [Bool])]
evaluateAll [] y = []
evaluateAll (x:xs) [] = evaluateAll xs $ nub $ permutations testimonyValidities
evaluateAll (x:xs) (y:ys) = if evaluateSentences x y
                            then [(x, y)] ++(evaluateAll (x:xs) ys)
                            else evaluateAll ([x]++xs) ys

-- guilty finds the boy who's guilty.
guilty :: [Boy]
guilty = [fst x| x<-evaluateAll boys $ permutations testimonyValidities]

Wel done!

@DylanBartels
Copy link
Contributor

Thank you for the feedback Bert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants