Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.haskell > #430 > unrolled thread
| Started by | Ho Yeung Lee <davidbenny2000@gmail.com> |
|---|---|
| First post | 2016-07-26 22:08 -0700 |
| Last post | 2016-07-27 20:20 -0700 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.haskell
how to generalize these two map into one map Ho Yeung Lee <davidbenny2000@gmail.com> - 2016-07-26 22:08 -0700
Re: how to generalize these two map into one map Mark Carroll <mtbc@bcs.org> - 2016-07-27 08:39 +0100
Re: how to generalize these two map into one map meInvent bbird <jobmattcon@gmail.com> - 2016-07-27 02:17 -0700
Re: how to generalize these two map into one map Mark Carroll <mtbc@bcs.org> - 2016-07-27 10:30 +0100
Re: how to generalize these two map into one map meInvent bbird <jobmattcon@gmail.com> - 2016-07-27 20:20 -0700
| From | Ho Yeung Lee <davidbenny2000@gmail.com> |
|---|---|
| Date | 2016-07-26 22:08 -0700 |
| Subject | how to generalize these two map into one map |
| Message-ID | <49f1ff1f-57f1-4f22-b943-fcbd28f6aac5@googlegroups.com> |
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?
[toc] | [next] | [standalone]
| From | Mark Carroll <mtbc@bcs.org> |
|---|---|
| Date | 2016-07-27 08:39 +0100 |
| Message-ID | <87shuvjzrp.fsf@ixod.org> |
| In reply to | #430 |
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
[toc] | [prev] | [next] | [standalone]
| From | meInvent bbird <jobmattcon@gmail.com> |
|---|---|
| Date | 2016-07-27 02:17 -0700 |
| Message-ID | <fafce7db-6ed3-4c1e-9c71-035636a7fd54@googlegroups.com> |
| In reply to | #431 |
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
[toc] | [prev] | [next] | [standalone]
| From | Mark Carroll <mtbc@bcs.org> |
|---|---|
| Date | 2016-07-27 10:30 +0100 |
| Message-ID | <87r3afpgvk.fsf@ixod.org> |
| In reply to | #432 |
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
[toc] | [prev] | [next] | [standalone]
| From | meInvent bbird <jobmattcon@gmail.com> |
|---|---|
| Date | 2016-07-27 20:20 -0700 |
| Message-ID | <3f7f428e-44cc-4cec-b778-e57054272463@googlegroups.com> |
| In reply to | #433 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.haskell
csiph-web