haskell - Apply a function to a list of items -
I have defined a function I have to apply this function in a list of items, but I'm stuck. Is it possible to use the map? I can not get it. (Only functions that can use recursion f) Edit to clarify some examples I should know how much money has been spent by defining a new function, assuming that Is it possible to use (function Am I thinking about it in the right direction? Assume that you have three logic functions: and where In your case the only difference is the sequence of arguments. For such issues, In your case this will probably give some results in the map (flip (FA) prices . f which will be given
value Item is
x stored inside a list of prices with [code] [[string, string, ante]]
a = string x = String value = int prices list = [(a, x, price)] fax ((a1, x1, price): ys). A == A1 & amp; Amp; X == x1 = value | Otherwise = FA x YS
< Code> pricesList = [("Apple", "iPod", 100), ("Apple", "iPhone", 200), ("Samsung", "Galaxy", 200)] Passure = [("Harry", 1 9 85, "Apple", ["iPhone", "iPod"]), ("George", 1983, "Samsung", ["Galaxy"])] * Main & gt;
spent code> F Inside of it)
* main & gt; "Its what's up to now"
itsThePerson name (n, _, _, _) = name == n InfoFrom name = (head filter (its peers name)) Money brand (_ , _, B, _) = B product (_, _, _, P) = P brand = brand = brand InfoPerson = info from the product infoFrom
map with
f to know the sum of the prices?
f will be
itemprice )
spent name = sum (map (itemprice (branding Name of the Xxx Prices List (Name of the Product)
f :: a -> gt - b -> c -> D
c list of values -
list :: [b] . Suppose that we have each
f < / Code> want to apply list Item with default and first arguments, so we can do something like this:
map (fxy) list
x :: a and
y :: b .
flip :
Comments
Post a Comment