• how to use dynamic variable programming in haskell?

    From Mark Carroll@21:1/5 to Ho Yeung Lee on Thu Oct 6 08:58:53 2016
    On 06 Oct 2016, Ho Yeung Lee wrote:

    how to convert string "001" into a dynamic variables a,b,c ,make a == 0 && b == 0 && c == 1 ?

    I'm not sure I understand your preface to this but,

    Prelude> let [a,b,c] = [ read [x] | x <- "001" ] :: [Int]
    Prelude> (a,b,c)
    (0,0,1)

    but if you get into any serious parsing then take a good luck at
    libraries like Parsec and Frisby.

    -- Mark

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ho Yeung Lee@21:1/5 to All on Thu Oct 6 01:07:56 2016
    i can parse already and got exactly which digit it return in espresso,

    i only do not know how to dynamic create variables

    if 3 variables, for example it will be a == 1 && b == 0 && c == 0

    if 4 variables, for example it will be a == 0 && b == 1 && c == 0 && d == 1

    but without
    let a =
    let b =
    let c =

    assignment before it write into expression of if statement.

    how to create this dynamic statement for if statement use ?

    Mark Carroll於 2016年10月6日星期四 UTC+8下午3時58分54秒寫道:
    On 06 Oct 2016, Ho Yeung Lee wrote:

    how to convert string "001" into a dynamic variables a,b,c ,make a == 0 && b
    == 0 && c == 1 ?

    I'm not sure I understand your preface to this but,

    Prelude> let [a,b,c] = [ read [x] | x <- "001" ] :: [Int]
    Prelude> (a,b,c)
    (0,0,1)

    but if you get into any serious parsing then take a good luck at
    libraries like Parsec and Frisby.

    -- Mark

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mark Carroll@21:1/5 to Ho Yeung Lee on Thu Oct 6 09:53:09 2016
    On 06 Oct 2016, Ho Yeung Lee wrote:

    i can parse already and got exactly which digit it return in espresso,

    i only do not know how to dynamic create variables

    if 3 variables, for example it will be a == 1 && b == 0 && c == 0

    if 4 variables, for example it will be a == 0 && b == 1 && c == 0 && d == 1

    but without
    let a =
    let b =
    let c =

    assignment before it write into expression of if statement.

    how to create this dynamic statement for if statement use ?

    Maybe it would be better to just keep them in a list? Might your if
    statement do better as pattern-matching?

    -- Mark

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