pattern matching to data inside a list

Is there a way to pattern match to a list argument and get a list? For example, I have this: -- A LayoutItem has a center position (point), and the four ints are -- "left width", "rigth width", "top height", and "bottom height" data LayoutItem = LayoutItem Point Int Int Int Int deriving Show -- This computes the left width of a group of composited LayoutItem. compositeLeftWidth :: [LayoutItem] -> Int compositeLeftWidth items = let itemsPosX = [ x | LayoutItem (Point (x,_)) _ _ _ _ <- items ] itemsLW = [ lw | LayoutItem _ lw _ _ _ <- items ] z = zipWith (\x y -> x-y+1) itemsPosX itemsLW in (minimum z) - 1 What I'm wondering is if I could somehow do something like compositeLeftWidth [ LayoutItem Point( x, _ ) lw _ _ _ ] = ... and that x and lw would each be the lists I'm calling itemsPosX and itemsLW above. Thanks, Mike PS Let me repeat my request to find out how to install SOE "on the library path." I know I'm impatient about this, but it seems simple enough, and it's driving me crazy that I can only write software in the same directory where I've installed SOE.

Is there a way to pattern match to a list argument and get a list? For example, I have this:
-- A LayoutItem has a center position (point), and the four ints are -- "left width", "rigth width", "top height", and "bottom height" data LayoutItem = LayoutItem Point Int Int Int Int deriving Show
-- This computes the left width of a group of composited LayoutItem. compositeLeftWidth :: [LayoutItem] -> Int compositeLeftWidth items = let itemsPosX = [ x | LayoutItem (Point (x,_)) _ _ _ _ <- items ] itemsLW = [ lw | LayoutItem _ lw _ _ _ <- items ] z = zipWith (\x y -> x-y+1) itemsPosX itemsLW in (minimum z) - 1
What I'm wondering is if I could somehow do something like
compositeLeftWidth [ LayoutItem Point( x, _ ) lw _ _ _ ] = ...
and that x and lw would each be the lists I'm calling itemsPosX and itemsLW above.
Thanks, Mike
That would be neat :-). But IIRC there is no syntax for that. However, if you are interested in other suggestions (by a very newbie, so
2009/3/27 Michael Mossey
participants (2)
-
Francesco Bochicchio
-
Michael Mossey