• where is wrong in my program

    From Ho Yeung Lee@21:1/5 to All on Thu Jul 28 02:01:47 2016
    https://gist.github.com/hoyeunglee/9016d6e583f4135c9b259ff8d8673c7b

    MA([1,2], MB([2,3], MC([3,4], [4,5])))

    i discover the function getAllTreesFromList
    needed 4 parameters in order to generate one function which contain 3 operators

    i have already chosen 4 parameters saved in allparams1

    *Main> let alltrees1a = [ (x, sum $ (eeval1 x)) | x <- allexprs1]

    <interactive>:377:38:
    Couldn't match expected type `Mree [Double]'
    with actual type `[Mree [Double]]'
    In the first argument of `eeval1', namely `x'
    In the second argument of `($)', namely `(eeval1 x)'
    In the expression: sum $ (eeval1 x)


    :l trees3a.hs
    let input2 mm = replicateM mm [(1,MA), (2,MB), (3,MC), (4,MD), (5,ME), (6,MF), (7,MG), (8,MH)]
    let {isSorted :: (Ord a) => [(a, Operation)] -> Bool; isSorted [] = True; isSorted [x] = True; isSorted (x:y:xs) = (fst x) > (fst y) && isSorted (y:xs)}
    let {doall mm = do let {input1 = input2 mm};writeFile ("logic3layer"++show(mm)++".txt") (unlines $ map show $ filter isSorted input1)}
    let input1 = input2 3
    let oplist = filter isSorted input1
    let getoperationlist = [map snd (oplist!!i) | i <- [0..((length oplist)-1)]]

    let fullytruerownum = 162
    let fullytrue = 162.0
    let logic3row = replicateM 3 [0.0, 1.0, 2.0]
    let logic3col = [[logic3row!!i!!3 | i <- [0..(81-1)]],[logic3row!!i!!2 | i <- [0..(81-1)]],[logic3row!!i!!1 | i <- [0..(81-1)]],[logic3row!!i!!0 | i <- [0..(81-1)]]]
    let allparams1 = replicateM 4 logic3col
    let alltrees1 nn = [getAllTreesFromList (getoperationlist!!nn) c | x <- allparams1, c <- [x]]
    let allexprs1 = alltrees1 40
    let alltrees1a = [ (x, sum $ (eeval1 x)) | x <- allexprs1]
    let alltrees1b = [ (eeval1 x, sum $ (eeval1 x)) | x <- allexprs1]
    let alltrees1c = [ (eeval1 x, (x, sum $ (eeval1 x))) | x <- allexprs1]
    let bb1map = filter (\n -> snd (snd n) < fullytrue) alltrees1c
    let bb1true = [ (x,162.0) | (x,162.0) <- alltrees1a ]
    let bb1others = filter (\n -> snd n < fullytrue) alltrees1b
    length alltrees1a
    length bb1true
    length bb1others

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ho Yeung Lee@21:1/5 to All on Thu Jul 28 02:07:32 2016
    i have tested with a small example

    getoperationlist!!40 is [MH,MD,MC]

    let test1 = getAllTreesFromList [MH,MD,MC] [[1,2],[2,3],[3,4],[4,5]]

    it can run and succeeded to generate


    but in large list, it has many error
    [*** Exception: Prelude.(!!): index too large



    Ho Yeung Lee於 2016年7月28日星期四 UTC+8下午5時01分50秒寫道:
    https://gist.github.com/hoyeunglee/9016d6e583f4135c9b259ff8d8673c7b

    MA([1,2], MB([2,3], MC([3,4], [4,5])))

    i discover the function getAllTreesFromList
    needed 4 parameters in order to generate one function which contain 3 operators

    i have already chosen 4 parameters saved in allparams1

    *Main> let alltrees1a = [ (x, sum $ (eeval1 x)) | x <- allexprs1]

    <interactive>:377:38:
    Couldn't match expected type `Mree [Double]'
    with actual type `[Mree [Double]]'
    In the first argument of `eeval1', namely `x'
    In the second argument of `($)', namely `(eeval1 x)'
    In the expression: sum $ (eeval1 x)


    :l trees3a.hs
    let input2 mm = replicateM mm [(1,MA), (2,MB), (3,MC), (4,MD), (5,ME), (6,MF), (7,MG), (8,MH)]
    let {isSorted :: (Ord a) => [(a, Operation)] -> Bool; isSorted [] = True; isSorted [x] = True; isSorted (x:y:xs) = (fst x) > (fst y) && isSorted (y:xs)}
    let {doall mm = do let {input1 = input2 mm};writeFile ("logic3layer"++show(mm)++".txt") (unlines $ map show $ filter isSorted input1)}
    let input1 = input2 3
    let oplist = filter isSorted input1
    let getoperationlist = [map snd (oplist!!i) | i <- [0..((length oplist)-1)]]

    let fullytruerownum = 162
    let fullytrue = 162.0
    let logic3row = replicateM 3 [0.0, 1.0, 2.0]
    let logic3col = [[logic3row!!i!!3 | i <- [0..(81-1)]],[logic3row!!i!!2 | i <- [0..(81-1)]],[logic3row!!i!!1 | i <- [0..(81-1)]],[logic3row!!i!!0 | i <- [0..(81-1)]]]
    let allparams1 = replicateM 4 logic3col
    let alltrees1 nn = [getAllTreesFromList (getoperationlist!!nn) c | x <- allparams1, c <- [x]]
    let allexprs1 = alltrees1 40
    let alltrees1a = [ (x, sum $ (eeval1 x)) | x <- allexprs1]
    let alltrees1b = [ (eeval1 x, sum $ (eeval1 x)) | x <- allexprs1]
    let alltrees1c = [ (eeval1 x, (x, sum $ (eeval1 x))) | x <- allexprs1]
    let bb1map = filter (\n -> snd (snd n) < fullytrue) alltrees1c
    let bb1true = [ (x,162.0) | (x,162.0) <- alltrees1a ]
    let bb1others = filter (\n -> snd n < fullytrue) alltrees1b
    length alltrees1a
    length bb1true
    length bb1others

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