I have never programmed before and i have just recently (1 week ago) started learning! The first course is functional programming, using Haskell.
I have a school assignment that I'd like to improve by removing one or two steps, but there's one pesky bug in my way.
Basically, I create a list and i get the result with the type [Integer], whereas I'd like to convert this to Integer, if possible? I've set my test function to accept the types Integer -> Integer -> Bool (takes two values, computes them, and returns a bool). The test function puts the values into two functions and compares their results.
I could just change the expected type to [Integer] (?) but that would eliminate the option of manually putting in values.
For my test cases I've chosen a few values and put them into lists. a = [0, 2, (-3)] and b = [0, 2, 4]. What I'd like to do when I call the function is to enter a and b as the values, instead of typing in each testcase every time. Is this possible? Example:
testFunction a b
instead of something like
testFunction Integer Integer.
I hope I made sense :-) Keep in mind I am just learning!
aandb, or just pairs of values liketestFunction 0 0,testFunction 2 2,testFunction (-3) 4?testFunction :: [Integer] -> [Integer] -> [Bool], which at each step takes the first elements of each list, runs your functiontestFunctionand then appends it to a list of previously calculated versions. See if you can think of a way to phrase that in Haskell.testAll :: [Integer] -> [Integer] -> [Bool];testAll (x:xs) (y:ys) = <something with "testAll xs ys">;testAll _ _ = [], where the last case catches the cases where either or both of the input lists are empty.