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

From meInvent bbird@21:1/5 to All on Sun Jul 17 23:58:24 2016
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 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

--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
• From Ben Bacarisse@21:1/5 to meInvent bbird on Mon Jul 18 10:15:28 2016
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 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.

--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
• From meInvent bbird@21:1/5 to Ben Bacarisse on Mon Jul 18 02:20:00 2016
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 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.

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