S SmartDocs
시리즈: haskell haskell 5 줄 · 업데이트 2026-02-03

exercise_7.hs

haskell/Week_6_Lab/exercise_7.hs

-- Define the riffle function
riffle :: [a] -> [a] -> [a]
riffle [] ys = ys  -- If the first list is empty, return the second list
riffle xs [] = xs  -- If the second list is empty, return the first list
riffle (x:xs) (y:ys) = x : y : riffle xs ys  -- Alternate elements from both lists recursively

관련 글