They ask me to recursively make that given 3 lists of integers, the reverse concatenation of the first two lists is concatenated in the last list. Example: invconc_aux [1,2,3] [4,5,6,7,8] [9,10] should look like [8,7,6,5,4,3,2,1,9,10 ]. I attach my code:
invconc_aux :: [Integer] -> [Integer] -> [Integer] -> [Integer]
invconc_aux [] [] w = w
invconc_aux s r w
| null s = invconc_aux s [head(tail r)] ++ ([head r] ++ w)
| otherwise = invconc_aux [head(tail s)] r ([head s] ++ w)
My idea is that until s
it is empty, the elements of s
at the beginning of are concatenated w
, and when s
it is empty, the elements of r
at the beginning of are concatenated w
. When s
and r
are both empty it will return w
.
In principle, the idea is fine. Instead of using the
head
and functionstail
, it uses the calling patterns , something like this: