Question: The code below is my Haskell code, how will it look like if I have to turn it in to Scala code? This is my

The code below is my Haskell code, how will it look like if I have to turn it in to Scala code?

This is my Haskell code:

luhn4 :: [Int] -> Bool

luhn4 ns | mod ((sum . altMap id luhnDouble . reverse) ns) 10 == 0 = True

| otherwise = False

[luhn4 is a function for checking the validity of card numbers of arbitrary lengths using altMap. luhn4 should accept a list of Int values to represent the digits of the card.]

[both 'altMap' and 'luhnDouble' are other fuctions, which are already done.]

[altMap: applies its 2 argument functions to successive elements in a list alternately, in turn about order. For example:-- altMap (+10) (+100) [0,1,2,3,4] gives: List(10, 101, 12, 103, 14).]

[luhnDouble: doubles a digit and subtracts 9 if the result is greater than 9. For example:--luhnDouble(3) gives (3*2) = 6, And luhnDouble(6) gives ((6*2) -9) = 3]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!