Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.haskell > #381 > unrolled thread

when map a tuple of double to a double, it return nothing

Started bymeInvent bbird <jobmattcon@gmail.com>
First post2016-07-17 23:58 -0700
Last post2016-07-18 02:20 -0700
Articles 3 — 2 participants

Back to article view | Back to comp.lang.haskell


Contents

  when map a tuple of double to a double, it return nothing meInvent bbird <jobmattcon@gmail.com> - 2016-07-17 23:58 -0700
    Re: when map a tuple of double to a double, it return nothing Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-07-18 10:15 +0100
      Re: when map a tuple of double to a double, it return nothing meInvent bbird <jobmattcon@gmail.com> - 2016-07-18 02:20 -0700

#381 — when map a tuple of double to a double, it return nothing

FrommeInvent bbird <jobmattcon@gmail.com>
Date2016-07-17 23:58 -0700
Subjectwhen map a tuple of double to a double, it return nothing
Message-ID<20d5aa48-72dd-4e67-a025-37e6b9c83144@googlegroups.com>
after checking many times, do not know where is wrong

when map a tuple of double to a double, it return nothing

import Data.List
import Control.Monad
import Math.Combinat
import System.IO
import Data.Map (Map)
import qualified Data.Map as Map
let allparams = replicateM 2 [0.0, 1.0]
let a1 = [0.0, 1.0, 1.0, 1.0]



let { op1 :: Map (Double, Double) Double; op1 = Map.fromList [((allparams!!i!!0, allparams!!i!!1), a1!!i) | i <- [0..3] ] }
Map.lookup (0.0,0.0) $ op1
Map.lookup (0.0,0.1) $ op1
Map.lookup (0.1,0.0) $ op1
Map.lookup (0.1,0.1) $ op1




*Main Data.Map Map> Map.lookup (0.0,0.0) $ op1
Just 0.0
*Main Data.Map Map> Map.lookup (0.0,0.1) $ op1
Nothing
*Main Data.Map Map> Map.lookup (0.1,0.0) $ op1
Nothing
*Main Data.Map Map> Map.lookup (0.1,0.1) $ op1
Nothing



below simple example, it works, 



let { op1a :: Map Integer Integer; op1a = Map.fromList [(1,2),(3,4),(3,2),(5,5)] }
Map.lookup 1 $ op1a
Map.lookup 3 $ op1a
Map.lookup 5 $ op1a

[toc] | [next] | [standalone]


#382

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-07-18 10:15 +0100
Message-ID<87twfni9xr.fsf@bsb.me.uk>
In reply to#381
meInvent bbird <jobmattcon@gmail.com> writes:

> after checking many times, do not know where is wrong
>
> when map a tuple of double to a double, it return nothing
>
> import Data.List
> import Control.Monad
> import Math.Combinat
> import System.IO
> import Data.Map (Map)
> import qualified Data.Map as Map
> let allparams = replicateM 2 [0.0, 1.0]
> let a1 = [0.0, 1.0, 1.0, 1.0]
>
>
> let { op1 :: Map (Double, Double) Double; op1 = Map.fromList
> [((allparams!!i!!0, allparams!!i!!1), a1!!i) | i <- [0..3] ] }
> Map.lookup (0.0,0.0) $ op1
> Map.lookup (0.0,0.1) $ op1
> Map.lookup (0.1,0.0) $ op1
> Map.lookup (0.1,0.1) $ op1
>
>
> *Main Data.Map Map> Map.lookup (0.0,0.0) $ op1
> Just 0.0
> *Main Data.Map Map> Map.lookup (0.0,0.1) $ op1
> Nothing
> *Main Data.Map Map> Map.lookup (0.1,0.0) $ op1
> Nothing
> *Main Data.Map Map> Map.lookup (0.1,0.1) $ op1
> Nothing

Check the data.  0.1 /= 1.0.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#383

FrommeInvent bbird <jobmattcon@gmail.com>
Date2016-07-18 02:20 -0700
Message-ID<bfd09a97-44c8-4aa2-b710-2a01aada9f13@googlegroups.com>
In reply to#382
i see now , thank you very much

On Monday, July 18, 2016 at 5:15:28 PM UTC+8, Ben Bacarisse wrote:
> meInvent bbird <jobmattcon@gmail.com> writes:
> 
> > after checking many times, do not know where is wrong
> >
> > when map a tuple of double to a double, it return nothing
> >
> > import Data.List
> > import Control.Monad
> > import Math.Combinat
> > import System.IO
> > import Data.Map (Map)
> > import qualified Data.Map as Map
> > let allparams = replicateM 2 [0.0, 1.0]
> > let a1 = [0.0, 1.0, 1.0, 1.0]
> >
> >
> > let { op1 :: Map (Double, Double) Double; op1 = Map.fromList
> > [((allparams!!i!!0, allparams!!i!!1), a1!!i) | i <- [0..3] ] }
> > Map.lookup (0.0,0.0) $ op1
> > Map.lookup (0.0,0.1) $ op1
> > Map.lookup (0.1,0.0) $ op1
> > Map.lookup (0.1,0.1) $ op1
> >
> >
> > *Main Data.Map Map> Map.lookup (0.0,0.0) $ op1
> > Just 0.0
> > *Main Data.Map Map> Map.lookup (0.0,0.1) $ op1
> > Nothing
> > *Main Data.Map Map> Map.lookup (0.1,0.0) $ op1
> > Nothing
> > *Main Data.Map Map> Map.lookup (0.1,0.1) $ op1
> > Nothing
> 
> Check the data.  0.1 /= 1.0.
> 
> <snip>
> -- 
> Ben.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.haskell


csiph-web