-
Notifications
You must be signed in to change notification settings - Fork 312
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
Turned exercise 039 into practice #2281
Conversation
@jahielkomu I was working on the issue you've linked :) Also, you've linked Exercise 037 in the link, rather than 039. |
practice/039/answer/impl.ml
Outdated
let rest = all_primes (a + 1) b in | ||
if is_prime a then a :: rest else rest | ||
|
||
|
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.
Remove spaces at the end of files, add new line.
@@ -0,0 +1,41 @@ | |||
|
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.
Remove space at the start and end of all files.
practice/039/ex.ml
Outdated
module Make(Tested: Testable) : sig val v : test end = struct | ||
open Tested | ||
|
||
let is_prime_tests = "is_prime" >::: [ |
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.
This question only asks for all_primes
and not is_prime
practice/039/ex.ml
Outdated
open OUnit2 | ||
|
||
module type Testable = sig | ||
val is_prime : int -> bool |
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.
Remove signature of is_prime
.
practice/039/work/impl.ml
Outdated
@@ -0,0 +1,2 @@ | |||
let prime_tests _ = failwith "Not yet implemented" |
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.
It should be all_primes
function
Hello @divyankachaudhari , sorry I thought you were working on Issues #2278 and #2211 Thank you for pointing out the error in linkage |
Hello @divyankachaudhari Please I have updated the PR. |
@jahielkomu Yes, |
I do understand what you are saying @divyankachaudhari |
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.
This would be better tested if the all the numbers in the returned list are tested to be actually prime or not. Take inspiration from PR #2236.
- Inline a list of primes in
ex.ml
- Turn the specified range into a value of type
(int * bool) list
- Turn that latter list into test cases, using
List.map
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.
Hello @cuihtlauac ,
I have indeed gained inspiration from PR #2236.
I however would like to say if a prime number doesn't fall in the list I inline then I may label it not prime
which won't be correct because a prime can fall outside the primes I inline. I hope I understood your review correctly.
Solutions I'm thinking of:
- Listing all the primes from 2 to 7920 and pattern matching on the list to generate tuples.
- Checking each number directly and then generating tuples..(this would mean including a function that checks if a number is prime)
What is your say @cuihtlauac ?
@divyankachaudhari if there is anything you can point out, please do so too.
Thanks
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.
PR #2236 is now mergved into folder 031. Take inspiration from that to test all the values in the range
@jahielkomu are you still working on this? |
Yes @cuihtlauac I am. |
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.
Fix end of files, none finishing with newline character
Hello @cuihtlauac, I hope you are well. I have updated the ex.ml file of practice/039 but solely to pick your mind. Workflow. It is after this stage that I get a bit confused. |
Hello @cuihtlauac I hope you are well. |
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've fixed the PR. Thanks @jahielkomu
Thanks for the assistance @cuihtlauac . |
If the input is above 200, it's just an untested value. |
This makes sense @cuihtlauac . Are there more issues we can work on as we delve deeper into Ocaml? |
Addresses #2200. Turns Exercise 039 into Practice
@cuihtlauac please kindly review