• how to compute one and filter it immediately rather than calculated all

    From meInvent bbird@21:1/5 to All on Thu Jul 21 05:07:47 2016
    *Main> let true3print = [(peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map), isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map))) | i <- [0..(
    99999-1)]]
    *Main> let true3M8 = [ x | (x,True) <- true3print ]

    above code, it calculated all in true3print first

    and then filter the whole result

    is it possible to calculated each and filter immediately and saved into list?

    if compute in this way, can it be faster?

    how to compute one and filter it immediately rather than calculated all and then filter the whole

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to meInvent bbird on Thu Jul 21 16:31:12 2016
    meInvent bbird <jobmattcon@gmail.com> writes:

    *Main> let true3print = [(peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map),
    isInfixOf "M8" (peval (replacewithoriginalformula
    (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map))) | i
    <- [0..(99999-1)]]
    *Main> let true3M8 = [ x | (x,True) <- true3print ]

    above code, it calculated all in true3print first

    and then filter the whole result

    Have you head of lazy evaluation? The list true3print is probably not calculated first, but only as needed. It will probably never exist in
    memory all at the same time.

    is it possible to calculated each and filter immediately and saved
    into list?

    Yes, of course. Your example is a bit messy so I don't really want to
    try re-write it but you can generate only the (_, True) values in a
    single list comprehension.

    if compute in this way, can it be faster?

    That depends on the calculations. It won't be significantly faster
    unless you can skip some big calculation for the False values and
    Haskell is clever. Take this:

    list = [(g x, f x) | x <- [1..20]]

    Neither f not g get get called yet, and if we filter like this:

    [x | (x,True) <- list]

    the function g is only called for those values which match (_,True). In
    other words, what might look faster:

    [g x | x <- [1..20], f x]

    does exactly the same calculation.

    how to compute one and filter it immediately rather than calculated
    all and then filter the whole

    You can do it just by adding a clause in the list comprehension as I did
    in the last example.

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to meInvent bbird on Thu Jul 21 19:47:55 2016
    after tested in small list, it succeed to filter and really faster

    when tested in very large list such as over hundred thousand in the list

    how to evaluate only one time?

    because length iterate whole list one time, the filter list iterate second time, it seems runs two times

    let lenbb3true = length bb3true
    let true3print = [peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map) | i <- [0..(100-1)], isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map)) ]
    writeFile "myfile3.txt" $ unlines true3print


    On Friday, July 22, 2016 at 10:30:04 AM UTC+8, meInvent bbird wrote:
    after changed to [g x | x <- [1..20], f x]

    got error when filter

    and there is another problem is about the length

    in this calculation, does it mean that it has to iterate and evaluate twice times of the whole list, one is length, another one is the filter list with true?

    let lenbb3true = length bb3true

    *Main> let true3print = [peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map) | i <- [0..(100-1)], isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map)
    bb1map)) ]

    *Main> let true3M8 = [ x | (x,True) <- true3print ]


    <interactive>:76:21:
    Couldn't match type `(t0, Bool)' with `[Char]'
    Expected type: String
    Actual type: (t0, Bool)
    In the pattern: (x, True)
    In a stmt of a list comprehension: (x, True) <- true3print
    In the expression: [x | (x, True) <- true3print]



    On Thursday, July 21, 2016 at 11:31:13 PM UTC+8, Ben Bacarisse wrote:
    meInvent bbird <jobmattcon@gmail.com> writes:

    *Main> let true3print = [(peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map),
    isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map))) | i
    <- [0..(99999-1)]]
    *Main> let true3M8 = [ x | (x,True) <- true3print ]

    above code, it calculated all in true3print first

    and then filter the whole result

    Have you head of lazy evaluation? The list true3print is probably not calculated first, but only as needed. It will probably never exist in memory all at the same time.

    is it possible to calculated each and filter immediately and saved
    into list?

    Yes, of course. Your example is a bit messy so I don't really want to
    try re-write it but you can generate only the (_, True) values in a
    single list comprehension.

    if compute in this way, can it be faster?

    That depends on the calculations. It won't be significantly faster
    unless you can skip some big calculation for the False values and
    Haskell is clever. Take this:

    list = [(g x, f x) | x <- [1..20]]

    Neither f not g get get called yet, and if we filter like this:

    [x | (x,True) <- list]

    the function g is only called for those values which match (_,True). In other words, what might look faster:

    [g x | x <- [1..20], f x]

    does exactly the same calculation.

    how to compute one and filter it immediately rather than calculated
    all and then filter the whole

    You can do it just by adding a clause in the list comprehension as I did
    in the last example.

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to Ben Bacarisse on Thu Jul 21 19:29:58 2016
    after changed to [g x | x <- [1..20], f x]

    got error when filter

    and there is another problem is about the length

    in this calculation, does it mean that it has to iterate and evaluate twice times of the whole list, one is length, another one is the filter list with true?

    let lenbb3true = length bb3true

    *Main> let true3print = [peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map) | i <- [0..(100-1)], isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map)
    ) ]

    *Main> let true3M8 = [ x | (x,True) <- true3print ]


    <interactive>:76:21:
    Couldn't match type `(t0, Bool)' with `[Char]'
    Expected type: String
    Actual type: (t0, Bool)
    In the pattern: (x, True)
    In a stmt of a list comprehension: (x, True) <- true3print
    In the expression: [x | (x, True) <- true3print]



    On Thursday, July 21, 2016 at 11:31:13 PM UTC+8, Ben Bacarisse wrote:
    meInvent bbird <jobmattcon@gmail.com> writes:

    *Main> let true3print = [(peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map),
    isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map))) | i
    <- [0..(99999-1)]]
    *Main> let true3M8 = [ x | (x,True) <- true3print ]

    above code, it calculated all in true3print first

    and then filter the whole result

    Have you head of lazy evaluation? The list true3print is probably not calculated first, but only as needed. It will probably never exist in
    memory all at the same time.

    is it possible to calculated each and filter immediately and saved
    into list?

    Yes, of course. Your example is a bit messy so I don't really want to
    try re-write it but you can generate only the (_, True) values in a
    single list comprehension.

    if compute in this way, can it be faster?

    That depends on the calculations. It won't be significantly faster
    unless you can skip some big calculation for the False values and
    Haskell is clever. Take this:

    list = [(g x, f x) | x <- [1..20]]

    Neither f not g get get called yet, and if we filter like this:

    [x | (x,True) <- list]

    the function g is only called for those values which match (_,True). In other words, what might look faster:

    [g x | x <- [1..20], f x]

    does exactly the same calculation.

    how to compute one and filter it immediately rather than calculated
    all and then filter the whole

    You can do it just by adding a clause in the list comprehension as I did
    in the last example.

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to meInvent bbird on Thu Jul 21 21:38:12 2016
    [g x | x <- [1..20], f x]

    i do not understand why i do not specify to filter true in f x
    and it can get the true?

    how do it know i must choose true?


    On Friday, July 22, 2016 at 10:47:57 AM UTC+8, meInvent bbird wrote:
    after tested in small list, it succeed to filter and really faster

    when tested in very large list such as over hundred thousand in the list

    how to evaluate only one time?

    because length iterate whole list one time, the filter list iterate second time, it seems runs two times

    let lenbb3true = length bb3true
    let true3print = [peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map) | i <- [0..(100-1)], isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map)) ]
    writeFile "myfile3.txt" $ unlines true3print


    On Friday, July 22, 2016 at 10:30:04 AM UTC+8, meInvent bbird wrote:
    after changed to [g x | x <- [1..20], f x]

    got error when filter

    and there is another problem is about the length

    in this calculation, does it mean that it has to iterate and evaluate twice times of the whole list, one is length, another one is the filter list with true?

    let lenbb3true = length bb3true

    *Main> let true3print = [peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map) | i <- [0..(100-1)], isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map)
    bb1map)) ]

    *Main> let true3M8 = [ x | (x,True) <- true3print ]


    <interactive>:76:21:
    Couldn't match type `(t0, Bool)' with `[Char]'
    Expected type: String
    Actual type: (t0, Bool)
    In the pattern: (x, True)
    In a stmt of a list comprehension: (x, True) <- true3print
    In the expression: [x | (x, True) <- true3print]



    On Thursday, July 21, 2016 at 11:31:13 PM UTC+8, Ben Bacarisse wrote:
    meInvent bbird <jobmattcon@gmail.com> writes:

    *Main> let true3print = [(peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map), isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map))) | i
    <- [0..(99999-1)]]
    *Main> let true3M8 = [ x | (x,True) <- true3print ]

    above code, it calculated all in true3print first

    and then filter the whole result

    Have you head of lazy evaluation? The list true3print is probably not calculated first, but only as needed. It will probably never exist in memory all at the same time.

    is it possible to calculated each and filter immediately and saved
    into list?

    Yes, of course. Your example is a bit messy so I don't really want to try re-write it but you can generate only the (_, True) values in a single list comprehension.

    if compute in this way, can it be faster?

    That depends on the calculations. It won't be significantly faster unless you can skip some big calculation for the False values and
    Haskell is clever. Take this:

    list = [(g x, f x) | x <- [1..20]]

    Neither f not g get get called yet, and if we filter like this:

    [x | (x,True) <- list]

    the function g is only called for those values which match (_,True). In other words, what might look faster:

    [g x | x <- [1..20], f x]

    does exactly the same calculation.

    how to compute one and filter it immediately rather than calculated
    all and then filter the whole

    You can do it just by adding a clause in the list comprehension as I did in the last example.

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to meInvent bbird on Fri Jul 22 09:40:14 2016
    meInvent bbird <jobmattcon@gmail.com> writes:

    [g x | x <- [1..20], f x]

    i do not understand why i do not specify to filter true in f x
    and it can get the true?

    how do it know i must choose true?

    Just because that's what the syntax means. After the | you write
    generators (like x <- [1..2]) or Boolean guards that refine what
    generated values are permitted. For example

    [i | i <- [1..20], True]

    is just [1..20] and

    [i | i <- [1..20], False]

    is just [].

    Note that writing the filtered list like this may be slower than the
    original version you had. It all depends on how the calculation of the
    pairs is done. Your example is rather complicated and that's putting me
    off looking at the details.

    <snip>
    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to meInvent bbird on Fri Jul 22 02:02:32 2016
    i use previous result and do combination and run again

    i run total 3 times, so there are 3 layers

    i replace the parameter of 3rd layer with 2nd layers result and
    replace 2nd layers result with 1st layer
    so, final there are only 3 columns of parameters, A,B,C


    let logic3col2 = [ x | (x,y) <- bb1others ]
    let allparams2 = replicateM 2 logic3col2
    let alltrees2 = [getAllTrees c | x <- allparams2, c <- [x]]
    allexprs2 :: [ Mree [Double] ]
    let allexprs2 = concat alltrees2
    let alltrees2a = [ (x, sum $ (eeval1 x)) | x <- allexprs2]
    let alltrees2b = [ (eeval1 x, sum $ (eeval1 x)) | x <- allexprs2]
    let alltrees2c = [ (eeval1 x, (x, sum $ (eeval1 x))) | x <- allexprs2]
    let bb2map = filter (\n -> snd (snd n) < fullytrue) alltrees2c
    let bb2true = [ (x,27.0) | (x,27.0) <- alltrees2a ]
    let bb2others = filter (\n -> snd n < fullytrue) alltrees2b
    --length alltrees2a
    --length bb2true
    --length bb2others

    --let test1 = fst (bb2true!!0)
    --replacewithoriginalformula test1 bb1map
    --let true2afterreplace = [(fst (bb2true!!i), sum $ (eeval1 (replacewithoriginalformula (fst (bb2true!!i)) bb1map))) | i <- [0..(length(bb2true)-1)]]
    --let bb2trueA = [ (x,8.0) | (x,8.0) <- true2afterreplace ]
    --length bb2trueA

    let logic3col3 = [ x | (x,y) <- bb2others ]
    let allparams3 = replicateM 2 logic3col3
    let alltrees3 = [getAllTrees c | x <- allparams3, c <- [x]]
    allexprs3 :: [ Mree [Double] ]
    let allexprs3 = concat alltrees3
    let alltrees3a = [ (x, sum $ (eeval1 x)) | x <- allexprs3]
    let alltrees3b = [ (eeval1 x, sum $ (eeval1 x)) | x <- allexprs3]
    let alltrees3c = [ (eeval1 x, (x, sum $ (eeval1 x))) | x <- allexprs3]
    let bb3map = filter (\n -> snd (snd n) < fullytrue) alltrees3c
    let bb3true = [ (x,27.0) | (x,27.0) <- alltrees3a ]
    let bb3others = filter (\n -> snd n < fullytrue) alltrees3b

    let lenbb3true = length bb3true
    let true3print = [peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map) | i <- [0..(lenbb3true-1)], isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map)
    ) ]
    writeFile "myfile3.txt" $ unlines true3print



    On Friday, July 22, 2016 at 4:57:10 PM UTC+8, meInvent bbird wrote:
    my detail is just combination of tree to generate formula,

    this generate a very large size list

    i have 8 types of logic for 3 valued logic

    a logic table with 3 columns A,B,C has 3^3 = 27 rows, search any formula which total sum of logic is 27
    fully true.



    let fullytruerownum = 27
    let fullytrue = 27.0
    let logic3row = replicateM 3 [0.0, 1.0, 2.0]
    let logic3col = [[logic3row!!i!!2 | i <- [0..(27-1)]],[logic3row!!i!!1 | i <- [0..(27-1)]],[logic3row!!i!!0 | i <- [0..(27-1)]]]
    let allparams1 = replicateM 2 logic3col
    let alltrees1 = [getAllTrees c | x <- allparams1, c <- [x]]

    allexprs1 :: [ Mree [Double] ]
    let allexprs1 = concat alltrees1
    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,27.0) | (x,27.0) <- alltrees1a ]
    let bb1others = filter (\n -> snd n < fullytrue) alltrees1b
    length alltrees1a
    length bb1true
    length bb1others


    M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M6(M5("C","A"),M4("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M5("C","A"),M6("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("C","A"),M4("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M5(M4("C","A"),M6("A","C"))) M1(M5(M5("B","A"),M5("B","A")),M5(M4("C","A"),M6("A","C"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("C","A"),M4("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M4(M5("C","B"),M6("A","C"))) M2(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M5("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M4("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M4(M5("C","B"),M6("A","C"))) M2(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M5("C","B")))


    On Friday, July 22, 2016 at 4:40:15 PM UTC+8, Ben Bacarisse wrote:
    meInvent bbird <jobmattcon@gmail.com> writes:

    [g x | x <- [1..20], f x]

    i do not understand why i do not specify to filter true in f x
    and it can get the true?

    how do it know i must choose true?

    Just because that's what the syntax means. After the | you write generators (like x <- [1..2]) or Boolean guards that refine what
    generated values are permitted. For example

    [i | i <- [1..20], True]

    is just [1..20] and

    [i | i <- [1..20], False]

    is just [].

    Note that writing the filtered list like this may be slower than the original version you had. It all depends on how the calculation of the pairs is done. Your example is rather complicated and that's putting me off looking at the details.

    <snip>
    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to meInvent bbird on Fri Jul 22 02:04:47 2016
    bb1true is first layers which are fully true,
    since it had already been true, so no need to go to 2nd layers

    i only choose bb1others which still not true

    and bb2others which still not true,

    and in final layer i choose only true result , bb3true


    On Friday, July 22, 2016 at 5:02:35 PM UTC+8, meInvent bbird wrote:
    i use previous result and do combination and run again

    i run total 3 times, so there are 3 layers

    i replace the parameter of 3rd layer with 2nd layers result and
    replace 2nd layers result with 1st layer
    so, final there are only 3 columns of parameters, A,B,C


    let logic3col2 = [ x | (x,y) <- bb1others ]
    let allparams2 = replicateM 2 logic3col2
    let alltrees2 = [getAllTrees c | x <- allparams2, c <- [x]]
    allexprs2 :: [ Mree [Double] ]
    let allexprs2 = concat alltrees2
    let alltrees2a = [ (x, sum $ (eeval1 x)) | x <- allexprs2]
    let alltrees2b = [ (eeval1 x, sum $ (eeval1 x)) | x <- allexprs2]
    let alltrees2c = [ (eeval1 x, (x, sum $ (eeval1 x))) | x <- allexprs2]
    let bb2map = filter (\n -> snd (snd n) < fullytrue) alltrees2c
    let bb2true = [ (x,27.0) | (x,27.0) <- alltrees2a ]
    let bb2others = filter (\n -> snd n < fullytrue) alltrees2b
    --length alltrees2a
    --length bb2true
    --length bb2others

    --let test1 = fst (bb2true!!0)
    --replacewithoriginalformula test1 bb1map
    --let true2afterreplace = [(fst (bb2true!!i), sum $ (eeval1 (replacewithoriginalformula (fst (bb2true!!i)) bb1map))) | i <- [0..(length(bb2true)-1)]]
    --let bb2trueA = [ (x,8.0) | (x,8.0) <- true2afterreplace ]
    --length bb2trueA

    let logic3col3 = [ x | (x,y) <- bb2others ]
    let allparams3 = replicateM 2 logic3col3
    let alltrees3 = [getAllTrees c | x <- allparams3, c <- [x]]
    allexprs3 :: [ Mree [Double] ]
    let allexprs3 = concat alltrees3
    let alltrees3a = [ (x, sum $ (eeval1 x)) | x <- allexprs3]
    let alltrees3b = [ (eeval1 x, sum $ (eeval1 x)) | x <- allexprs3]
    let alltrees3c = [ (eeval1 x, (x, sum $ (eeval1 x))) | x <- allexprs3]
    let bb3map = filter (\n -> snd (snd n) < fullytrue) alltrees3c
    let bb3true = [ (x,27.0) | (x,27.0) <- alltrees3a ]
    let bb3others = filter (\n -> snd n < fullytrue) alltrees3b

    let lenbb3true = length bb3true
    let true3print = [peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map) | i <- [0..(lenbb3true-1)], isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map)
    bb1map)) ]
    writeFile "myfile3.txt" $ unlines true3print



    On Friday, July 22, 2016 at 4:57:10 PM UTC+8, meInvent bbird wrote:
    my detail is just combination of tree to generate formula,

    this generate a very large size list

    i have 8 types of logic for 3 valued logic

    a logic table with 3 columns A,B,C has 3^3 = 27 rows, search any formula which total sum of logic is 27
    fully true.



    let fullytruerownum = 27
    let fullytrue = 27.0
    let logic3row = replicateM 3 [0.0, 1.0, 2.0]
    let logic3col = [[logic3row!!i!!2 | i <- [0..(27-1)]],[logic3row!!i!!1 | i <- [0..(27-1)]],[logic3row!!i!!0 | i <- [0..(27-1)]]]
    let allparams1 = replicateM 2 logic3col
    let alltrees1 = [getAllTrees c | x <- allparams1, c <- [x]]

    allexprs1 :: [ Mree [Double] ]
    let allexprs1 = concat alltrees1
    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,27.0) | (x,27.0) <- alltrees1a ]
    let bb1others = filter (\n -> snd n < fullytrue) alltrees1b
    length alltrees1a
    length bb1true
    length bb1others


    M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M6(M5("C","A"),M4("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M5("C","A"),M6("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("C","A"),M4("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M5(M4("C","A"),M6("A","C"))) M1(M5(M5("B","A"),M5("B","A")),M5(M4("C","A"),M6("A","C"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("C","A"),M4("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M4(M5("C","B"),M6("A","C"))) M2(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M5("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M4("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M4(M5("C","B"),M6("A","C"))) M2(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M5("C","B")))


    On Friday, July 22, 2016 at 4:40:15 PM UTC+8, Ben Bacarisse wrote:
    meInvent bbird <jobmattcon@gmail.com> writes:

    [g x | x <- [1..20], f x]

    i do not understand why i do not specify to filter true in f x
    and it can get the true?

    how do it know i must choose true?

    Just because that's what the syntax means. After the | you write generators (like x <- [1..2]) or Boolean guards that refine what generated values are permitted. For example

    [i | i <- [1..20], True]

    is just [1..20] and

    [i | i <- [1..20], False]

    is just [].

    Note that writing the filtered list like this may be slower than the original version you had. It all depends on how the calculation of the pairs is done. Your example is rather complicated and that's putting me off looking at the details.

    <snip>
    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to Ben Bacarisse on Fri Jul 22 01:57:09 2016
    my detail is just combination of tree to generate formula,

    this generate a very large size list

    i have 8 types of logic for 3 valued logic

    a logic table with 3 columns A,B,C has 3^3 = 27 rows, search any formula which total sum of logic is 27
    fully true.



    let fullytruerownum = 27
    let fullytrue = 27.0
    let logic3row = replicateM 3 [0.0, 1.0, 2.0]
    let logic3col = [[logic3row!!i!!2 | i <- [0..(27-1)]],[logic3row!!i!!1 | i <- [0..(27-1)]],[logic3row!!i!!0 | i <- [0..(27-1)]]]
    let allparams1 = replicateM 2 logic3col
    let alltrees1 = [getAllTrees c | x <- allparams1, c <- [x]]

    allexprs1 :: [ Mree [Double] ]
    let allexprs1 = concat alltrees1
    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,27.0) | (x,27.0) <- alltrees1a ]
    let bb1others = filter (\n -> snd n < fullytrue) alltrees1b
    length alltrees1a
    length bb1true
    length bb1others


    M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M6(M5("C","A"),M4("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M5("C","A"),M6("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("C","A"),M4("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M5(M4("C","A"),M6("A","C"))) M1(M5(M5("B","A"),M5("B","A")),M5(M4("C","A"),M6("A","C"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("C","A"),M4("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M4(M5("C","B"),M6("A","C"))) M2(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M5("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M4("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M4(M5("C","B"),M6("A","C"))) M2(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M5("C","B")))


    On Friday, July 22, 2016 at 4:40:15 PM UTC+8, Ben Bacarisse wrote:
    meInvent bbird <jobmattcon@gmail.com> writes:

    [g x | x <- [1..20], f x]

    i do not understand why i do not specify to filter true in f x
    and it can get the true?

    how do it know i must choose true?

    Just because that's what the syntax means. After the | you write
    generators (like x <- [1..2]) or Boolean guards that refine what
    generated values are permitted. For example

    [i | i <- [1..20], True]

    is just [1..20] and

    [i | i <- [1..20], False]

    is just [].

    Note that writing the filtered list like this may be slower than the
    original version you had. It all depends on how the calculation of the
    pairs is done. Your example is rather complicated and that's putting me
    off looking at the details.

    <snip>
    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to meInvent bbird on Fri Jul 22 04:33:12 2016
    sorry i made a mistake,

    i forget to multiply 2, it should be 54, not 27 in 3 valued logic


    On Friday, July 22, 2016 at 5:04:50 PM UTC+8, meInvent bbird wrote:
    bb1true is first layers which are fully true,
    since it had already been true, so no need to go to 2nd layers

    i only choose bb1others which still not true

    and bb2others which still not true,

    and in final layer i choose only true result , bb3true


    On Friday, July 22, 2016 at 5:02:35 PM UTC+8, meInvent bbird wrote:
    i use previous result and do combination and run again

    i run total 3 times, so there are 3 layers

    i replace the parameter of 3rd layer with 2nd layers result and
    replace 2nd layers result with 1st layer
    so, final there are only 3 columns of parameters, A,B,C


    let logic3col2 = [ x | (x,y) <- bb1others ]
    let allparams2 = replicateM 2 logic3col2
    let alltrees2 = [getAllTrees c | x <- allparams2, c <- [x]]
    allexprs2 :: [ Mree [Double] ]
    let allexprs2 = concat alltrees2
    let alltrees2a = [ (x, sum $ (eeval1 x)) | x <- allexprs2]
    let alltrees2b = [ (eeval1 x, sum $ (eeval1 x)) | x <- allexprs2]
    let alltrees2c = [ (eeval1 x, (x, sum $ (eeval1 x))) | x <- allexprs2]
    let bb2map = filter (\n -> snd (snd n) < fullytrue) alltrees2c
    let bb2true = [ (x,27.0) | (x,27.0) <- alltrees2a ]
    let bb2others = filter (\n -> snd n < fullytrue) alltrees2b
    --length alltrees2a
    --length bb2true
    --length bb2others

    --let test1 = fst (bb2true!!0)
    --replacewithoriginalformula test1 bb1map
    --let true2afterreplace = [(fst (bb2true!!i), sum $ (eeval1 (replacewithoriginalformula (fst (bb2true!!i)) bb1map))) | i <- [0..(length(bb2true)-1)]]
    --let bb2trueA = [ (x,8.0) | (x,8.0) <- true2afterreplace ]
    --length bb2trueA

    let logic3col3 = [ x | (x,y) <- bb2others ]
    let allparams3 = replicateM 2 logic3col3
    let alltrees3 = [getAllTrees c | x <- allparams3, c <- [x]]
    allexprs3 :: [ Mree [Double] ]
    let allexprs3 = concat alltrees3
    let alltrees3a = [ (x, sum $ (eeval1 x)) | x <- allexprs3]
    let alltrees3b = [ (eeval1 x, sum $ (eeval1 x)) | x <- allexprs3]
    let alltrees3c = [ (eeval1 x, (x, sum $ (eeval1 x))) | x <- allexprs3]
    let bb3map = filter (\n -> snd (snd n) < fullytrue) alltrees3c
    let bb3true = [ (x,27.0) | (x,27.0) <- alltrees3a ]
    let bb3others = filter (\n -> snd n < fullytrue) alltrees3b

    let lenbb3true = length bb3true
    let true3print = [peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map) | i <- [0..(lenbb3true-1)], isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map)
    bb1map)) ]
    writeFile "myfile3.txt" $ unlines true3print



    On Friday, July 22, 2016 at 4:57:10 PM UTC+8, meInvent bbird wrote:
    my detail is just combination of tree to generate formula,

    this generate a very large size list

    i have 8 types of logic for 3 valued logic

    a logic table with 3 columns A,B,C has 3^3 = 27 rows, search any formula which total sum of logic is 27
    fully true.



    let fullytruerownum = 27
    let fullytrue = 27.0
    let logic3row = replicateM 3 [0.0, 1.0, 2.0]
    let logic3col = [[logic3row!!i!!2 | i <- [0..(27-1)]],[logic3row!!i!!1 | i <- [0..(27-1)]],[logic3row!!i!!0 | i <- [0..(27-1)]]]
    let allparams1 = replicateM 2 logic3col
    let alltrees1 = [getAllTrees c | x <- allparams1, c <- [x]]

    allexprs1 :: [ Mree [Double] ]
    let allexprs1 = concat alltrees1
    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,27.0) | (x,27.0) <- alltrees1a ]
    let bb1others = filter (\n -> snd n < fullytrue) alltrees1b
    length alltrees1a
    length bb1true
    length bb1others


    M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M6(M5("C","A"),M4("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M5("C","A"),M6("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("C","A"),M4("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M5(M4("C","A"),M6("A","C"))) M1(M5(M5("B","A"),M5("B","A")),M5(M4("C","A"),M6("A","C"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("C","A"),M4("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M4(M5("C","B"),M6("A","C"))) M2(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M5("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M4("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M4(M5("C","B"),M6("A","C"))) M2(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M5("C","B")))


    On Friday, July 22, 2016 at 4:40:15 PM UTC+8, Ben Bacarisse wrote:
    meInvent bbird <jobmattcon@gmail.com> writes:

    [g x | x <- [1..20], f x]

    i do not understand why i do not specify to filter true in f x
    and it can get the true?

    how do it know i must choose true?

    Just because that's what the syntax means. After the | you write generators (like x <- [1..2]) or Boolean guards that refine what generated values are permitted. For example

    [i | i <- [1..20], True]

    is just [1..20] and

    [i | i <- [1..20], False]

    is just [].

    Note that writing the filtered list like this may be slower than the original version you had. It all depends on how the calculation of the pairs is done. Your example is rather complicated and that's putting me
    off looking at the details.

    <snip>
    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to meInvent bbird on Sat Jul 23 02:36:09 2016
    i succeeded to search a number of results in layer 2 which sum result is 54 for 3 columns A,B,C

    but in layer 3, it run a very long time,

    layer 3 , 3 columns
    i spent 4 hours to run that there is still no one result but still running.

    and now

    i run

    layer 3 , 3 columns which i try descending order
    [f x | x <- [len(list)-1, len(list)-1..0 ]

    layer 4 , 4 columns

    at the same time

    https://drive.google.com/file/d/0Bxs_ao6uuBDUd1B5Nk5RRzY0Ync/view?usp=sharing

    is there any more good suggestions to improve speed and memory?


    On Friday, July 22, 2016 at 7:33:14 PM UTC+8, meInvent bbird wrote:
    sorry i made a mistake,

    i forget to multiply 2, it should be 54, not 27 in 3 valued logic


    On Friday, July 22, 2016 at 5:04:50 PM UTC+8, meInvent bbird wrote:
    bb1true is first layers which are fully true,
    since it had already been true, so no need to go to 2nd layers

    i only choose bb1others which still not true

    and bb2others which still not true,

    and in final layer i choose only true result , bb3true


    On Friday, July 22, 2016 at 5:02:35 PM UTC+8, meInvent bbird wrote:
    i use previous result and do combination and run again

    i run total 3 times, so there are 3 layers

    i replace the parameter of 3rd layer with 2nd layers result and
    replace 2nd layers result with 1st layer
    so, final there are only 3 columns of parameters, A,B,C


    let logic3col2 = [ x | (x,y) <- bb1others ]
    let allparams2 = replicateM 2 logic3col2
    let alltrees2 = [getAllTrees c | x <- allparams2, c <- [x]]
    allexprs2 :: [ Mree [Double] ]
    let allexprs2 = concat alltrees2
    let alltrees2a = [ (x, sum $ (eeval1 x)) | x <- allexprs2]
    let alltrees2b = [ (eeval1 x, sum $ (eeval1 x)) | x <- allexprs2]
    let alltrees2c = [ (eeval1 x, (x, sum $ (eeval1 x))) | x <- allexprs2] let bb2map = filter (\n -> snd (snd n) < fullytrue) alltrees2c
    let bb2true = [ (x,27.0) | (x,27.0) <- alltrees2a ]
    let bb2others = filter (\n -> snd n < fullytrue) alltrees2b
    --length alltrees2a
    --length bb2true
    --length bb2others

    --let test1 = fst (bb2true!!0)
    --replacewithoriginalformula test1 bb1map
    --let true2afterreplace = [(fst (bb2true!!i), sum $ (eeval1 (replacewithoriginalformula (fst (bb2true!!i)) bb1map))) | i <- [0..(length(bb2true)-1)]]
    --let bb2trueA = [ (x,8.0) | (x,8.0) <- true2afterreplace ]
    --length bb2trueA

    let logic3col3 = [ x | (x,y) <- bb2others ]
    let allparams3 = replicateM 2 logic3col3
    let alltrees3 = [getAllTrees c | x <- allparams3, c <- [x]]
    allexprs3 :: [ Mree [Double] ]
    let allexprs3 = concat alltrees3
    let alltrees3a = [ (x, sum $ (eeval1 x)) | x <- allexprs3]
    let alltrees3b = [ (eeval1 x, sum $ (eeval1 x)) | x <- allexprs3]
    let alltrees3c = [ (eeval1 x, (x, sum $ (eeval1 x))) | x <- allexprs3] let bb3map = filter (\n -> snd (snd n) < fullytrue) alltrees3c
    let bb3true = [ (x,27.0) | (x,27.0) <- alltrees3a ]
    let bb3others = filter (\n -> snd n < fullytrue) alltrees3b

    let lenbb3true = length bb3true
    let true3print = [peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map) bb1map) | i <- [0..(lenbb3true-1)], isInfixOf "M8" (peval (replacewithoriginalformula (replacewithoriginalformula (fst (bb3true!!i)) bb2map)
    bb1map)) ]
    writeFile "myfile3.txt" $ unlines true3print



    On Friday, July 22, 2016 at 4:57:10 PM UTC+8, meInvent bbird wrote:
    my detail is just combination of tree to generate formula,

    this generate a very large size list

    i have 8 types of logic for 3 valued logic

    a logic table with 3 columns A,B,C has 3^3 = 27 rows, search any formula which total sum of logic is 27
    fully true.



    let fullytruerownum = 27
    let fullytrue = 27.0
    let logic3row = replicateM 3 [0.0, 1.0, 2.0]
    let logic3col = [[logic3row!!i!!2 | i <- [0..(27-1)]],[logic3row!!i!!1 | i <- [0..(27-1)]],[logic3row!!i!!0 | i <- [0..(27-1)]]]
    let allparams1 = replicateM 2 logic3col
    let alltrees1 = [getAllTrees c | x <- allparams1, c <- [x]]

    allexprs1 :: [ Mree [Double] ]
    let allexprs1 = concat alltrees1
    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,27.0) | (x,27.0) <- alltrees1a ]
    let bb1others = filter (\n -> snd n < fullytrue) alltrees1b
    length alltrees1a
    length bb1true
    length bb1others


    M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M2(M5(M5("B","A"),M5("B","A")),M5(M5("C","A"),M5("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M6(M5("C","A"),M4("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M5("C","A"),M6("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("C","A"),M4("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M5(M4("C","A"),M6("A","C"))) M1(M5(M5("B","A"),M5("B","A")),M5(M4("C","A"),M6("A","C"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("C","A"),M4("C","A"))) M1(M5(M5("B","A"),M5("B","A")),M4(M5("C","B"),M6("A","C"))) M2(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M5("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M4("C","B"))) M1(M5(M5("B","A"),M5("B","A")),M4(M5("C","B"),M6("A","C"))) M2(M5(M5("B","A"),M5("B","A")),M6(M6("A","C"),M5("C","B")))


    On Friday, July 22, 2016 at 4:40:15 PM UTC+8, Ben Bacarisse wrote:
    meInvent bbird <jobmattcon@gmail.com> writes:

    [g x | x <- [1..20], f x]

    i do not understand why i do not specify to filter true in f x
    and it can get the true?

    how do it know i must choose true?

    Just because that's what the syntax means. After the | you write generators (like x <- [1..2]) or Boolean guards that refine what generated values are permitted. For example

    [i | i <- [1..20], True]

    is just [1..20] and

    [i | i <- [1..20], False]

    is just [].

    Note that writing the filtered list like this may be slower than the original version you had. It all depends on how the calculation of the
    pairs is done. Your example is rather complicated and that's putting me
    off looking at the details.

    <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 25 00:55:31 2016
    Thanks , succeed to run

    On Friday, July 22, 2016 at 4:40:15 PM UTC+8, Ben Bacarisse wrote:
    meInvent bbird <jobmattcon@gmail.com> writes:

    [g x | x <- [1..20], f x]

    i do not understand why i do not specify to filter true in f x
    and it can get the true?

    how do it know i must choose true?

    Just because that's what the syntax means. After the | you write
    generators (like x <- [1..2]) or Boolean guards that refine what
    generated values are permitted. For example

    [i | i <- [1..20], True]

    is just [1..20] and

    [i | i <- [1..20], False]

    is just [].

    Note that writing the filtered list like this may be slower than the
    original version you had. It all depends on how the calculation of the
    pairs is done. Your example is rather complicated and that's putting me
    off looking at the details.

    <snip>
    --
    Ben.

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