Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+How might these stem from country and regional cultures?

Answered: 1 week ago