• how to generalize these two map into one map

    From Ho Yeung Lee@21:1/5 to All on Tue Jul 26 22:08:17 2016
    import Data.Foldable
    let aa = map (+1.2) [1,2]
    let bb = map (+1.4) [2,3]

    i find foldr, but how to use it for above two map?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mark Carroll@21:1/5 to Ho Yeung Lee on Wed Jul 27 08:39:22 2016
    On 27 Jul 2016, Ho Yeung Lee wrote:

    import Data.Foldable
    let aa = map (+1.2) [1,2]
    let bb = map (+1.4) [2,3]

    i find foldr, but how to use it for above two map?

    I am not sure for what result you are hoping, but perhaps "zip" can
    help?

    -- Mark

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mark Carroll@21:1/5 to meInvent bbird on Wed Jul 27 10:30:55 2016
    On 27 Jul 2016, meInvent bbird wrote:

    i do not know result too,
    this is why i need to compile and run it to show this magic result

    *Main Data.Foldable> foldr ((map (+1.2) [1,2]) . (map (+1.4) [2,3])) 1.0

    Exactly what were you hoping that this would do, though?

    -- Mark

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to Mark Carroll on Wed Jul 27 20:20:09 2016
    i do not familiar with the syntax,

    what is the correct way to write for run it?


    On Wednesday, July 27, 2016 at 5:30:56 PM UTC+8, Mark Carroll wrote:
    On 27 Jul 2016, meInvent bbird wrote:

    i do not know result too,
    this is why i need to compile and run it to show this magic result

    *Main Data.Foldable> foldr ((map (+1.2) [1,2]) . (map (+1.4) [2,3])) 1.0

    Exactly what were you hoping that this would do, though?

    -- Mark

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to Mark Carroll on Wed Jul 27 02:17:43 2016
    i do not know result too,
    this is why i need to compile and run it to show this magic result


    *Main Data.Foldable> foldr ((map (+1.2) [1,2]) . (map (+1.4) [2,3])) 1.0

    <interactive>:18:1:
    Ambiguous occurrence `foldr'
    It could refer to either `Data.List.foldr',
    imported from `Data.List' at trees3a.hs:1:1-16
    (and originally defined in `GHC.Base')
    or `Data.Foldable.foldr', imported from `Data.Foldable'
    *Main Data.Foldable> foldr ((map (+1.2) [1,2]) . (map (+1.4) [2,3])) [1.0]

    <interactive>:19:1:
    Ambiguous occurrence `foldr'
    It could refer to either `Data.List.foldr',
    imported from `Data.List' at trees3a.hs:1:1-16
    (and originally defined in `GHC.Base')
    or `Data.Foldable.foldr', imported from `Data.Foldable'
    *Main Data.Foldable> Data.Foldable.foldr ((map (+1.2) [1,2]) . (map (+1.4) [2,3])) [1.0]

    <interactive>:20:23:
    Couldn't match expected type `b0 -> [t1] -> [t1]'
    with actual type `[b1]'
    In the return type of a call of `map'
    Probable cause: `map' is applied to too many arguments
    In the first argument of `(.)', namely `(map (+ 1.2) [1, 2])'
    In the first argument of `Data.Foldable.foldr', namely
    `((map (+ 1.2) [1, 2]) . (map (+ 1.4) [2, 3]))'

    <interactive>:20:44:
    Couldn't match expected type `a0 -> b0' with actual type `[b2]'
    In the return type of a call of `map'
    Probable cause: `map' is applied to too many arguments
    In the second argument of `(.)', namely `(map (+ 1.4) [2, 3])'
    In the first argument of `Data.Foldable.foldr', namely
    `((map (+ 1.2) [1, 2]) . (map (+ 1.4) [2, 3]))'
    *Main Data.Foldable> Data.Foldable.foldr ((map (+1.2) [1,2]) . (map (+1.4) [2,3])) [1.0,2.0]

    <interactive>:21:23:
    Couldn't match expected type `b0 -> [t1] -> [t1]'
    with actual type `[b1]'
    In the return type of a call of `map'
    Probable cause: `map' is applied to too many arguments
    In the first argument of `(.)', namely `(map (+ 1.2) [1, 2])'
    In the first argument of `Data.Foldable.foldr', namely
    `((map (+ 1.2) [1, 2]) . (map (+ 1.4) [2, 3]))'

    <interactive>:21:44:
    Couldn't match expected type `a0 -> b0' with actual type `[b2]'
    In the return type of a call of `map'
    Probable cause: `map' is applied to too many arguments
    In the second argument of `(.)', namely `(map (+ 1.4) [2, 3])'
    In the first argument of `Data.Foldable.foldr', namely
    `((map (+ 1.2) [1, 2]) . (map (+ 1.4) [2, 3]))'
    *Main Data.Foldable> foldr ((map (+1.2) [1,2]) . (map (+1.4) [2,3])) [1.0,2.0]

    <interactive>:22:1:
    Ambiguous occurrence `foldr'
    It could refer to either `Data.List.foldr',
    imported from `Data.List' at trees3a.hs:1:1-16
    (and originally defined in `GHC.Base')
    or `Data.Foldable.foldr', imported from `Data.Foldable'
    *Main Data.Foldable> foldr ((map (+1.2) [1,2]) . (map (+1.4) [2,3])) [1.0,2.0]


    On Wednesday, July 27, 2016 at 3:39:24 PM UTC+8, Mark Carroll wrote:
    On 27 Jul 2016, Ho Yeung Lee wrote:

    import Data.Foldable
    let aa = map (+1.2) [1,2]
    let bb = map (+1.4) [2,3]

    i find foldr, but how to use it for above two map?

    I am not sure for what result you are hoping, but perhaps "zip" can
    help?

    -- Mark

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)