Skip to main content
Add link for Haskell program
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698
Became Hot Network Question
deleted 19 characters in body
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698
data Ragged a = Ragged (Either a [Ragged a])  deriving (Show)  zip' :: Ragged a -> Ragged b -> Ragged (a, b) zip' (Ragged x) (Ragged y) = Ragged $ go x y where go :: Either a [Ragged a] -> Either b [Ragged b] -> Either (a,b) [Ragged (a,b)] go (Left x) (Left y) = Left (x, y) go (Left x) (Right ys) = Right $ (zip' $ Ragged $ Left x) <$> ys go (Right xs) (Left y) = Right $ (flip zip' $ Ragged $ Left y) <$> xs go (Right xs) (Right ys) = Right $ zipWith zip' xs ys 
data Ragged a = Ragged (Either a [Ragged a])  deriving (Show)  zip' :: Ragged a -> Ragged b -> Ragged (a, b) zip' (Ragged x) (Ragged y) = Ragged $ go x y where go :: Either a [Ragged a] -> Either b [Ragged b] -> Either (a,b) [Ragged (a,b)] go (Left x) (Left y) = Left (x, y) go (Left x) (Right ys) = Right $ (zip' $ Ragged $ Left x) <$> ys go (Right xs) (Left y) = Right $ (flip zip' $ Ragged $ Left y) <$> xs go (Right xs) (Right ys) = Right $ zipWith zip' xs ys 
data Ragged a = Ragged (Either a [Ragged a]) zip' :: Ragged a -> Ragged b -> Ragged (a, b) zip' (Ragged x) (Ragged y) = Ragged $ go x y where go :: Either a [Ragged a] -> Either b [Ragged b] -> Either (a,b) [Ragged (a,b)] go (Left x) (Left y) = Left (x, y) go (Left x) (Right ys) = Right $ (zip' $ Ragged $ Left x) <$> ys go (Right xs) (Left y) = Right $ (flip zip' $ Ragged $ Left y) <$> xs go (Right xs) (Right ys) = Right $ zipWith zip' xs ys 
added 6 characters in body
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698
zip 1[1] [2[[2,3,[5,4]]4]]] = [[[(1,2),(1,3),[(1,5),(1,4)]]]]] zip [1,2] [3,[4,5]] = [(1,3),[(2,4),(2,5)]] zip [[2,3],4] [1,[6,7]] = [[(2,1),(3,1)],[(4,6),(4,7)]] 
zip 1 [2,3,[5,4]] = [(1,2),(1,3),[(1,5),(1,4)]] zip [1,2] [3,[4,5]] = [(1,3),[(2,4),(2,5)]] zip [[2,3],4] [1,[6,7]] = [[(2,1),(3,1)],[(4,6),(4,7)]] 
zip [1] [[2,3,[5,4]]] = [[(1,2),(1,3),[(1,5),(1,4)]]] zip [1,2] [3,[4,5]] = [(1,3),[(2,4),(2,5)]] zip [[2,3],4] [1,[6,7]] = [[(2,1),(3,1)],[(4,6),(4,7)]] 
edited body
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698
Loading
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 698
Loading