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


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

how to use dynamic variable programming in haskell?

Started byHo Yeung Lee <davidbenny2000@gmail.com>
First post2016-10-06 00:52 -0700
Last post2016-10-06 09:53 +0100
Articles 4 — 2 participants

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


Contents

  how to use dynamic variable programming in haskell? Ho Yeung Lee <davidbenny2000@gmail.com> - 2016-10-06 00:52 -0700
    Re: how to use dynamic variable programming in haskell? Mark Carroll <mtbc@bcs.org> - 2016-10-06 08:58 +0100
      Re: how to use dynamic variable programming in haskell? Ho Yeung Lee <davidbenny2000@gmail.com> - 2016-10-06 01:07 -0700
        Re: how to use dynamic variable programming in haskell? Mark Carroll <mtbc@bcs.org> - 2016-10-06 09:53 +0100

#460 — how to use dynamic variable programming in haskell?

FromHo Yeung Lee <davidbenny2000@gmail.com>
Date2016-10-06 00:52 -0700
Subjecthow to use dynamic variable programming in haskell?
Message-ID<210c7a80-235b-4c56-9bb8-1b2872626986@googlegroups.com>
i make use of espresso in haskell
and would like to use one recursive if statement in function 
to do all if then else work be reused into whole program

but a, b, c are dynamic created, how can it be used by other programming statement?

and how to write?

this code write to file

import Math.Combinat
import Control.Monad
let logic3row = replicateM 3 [0.0, 1.0]
let output = [0,1,1,1,0,1,0,1]
sequence_ [appendFile "inputfile3" $ (concat [show (truncate (logic3row!!jj!!ii)) | ii <- [0..(length(logic3row!!jj)-1)]]) ++ " " ++ show (output!!jj) ++ "\n" | jj <- [0..(length(output)-1)]]
--sequence_ [appendFile "inputfile3" $ (show (output!!jj)) ++ "\n" | jj <- [0..(length(output)-1)]]

and i wrote another code which can read output file generated by espresso
which are used to get 

something like

y = C + A.B

which in format

001 1
110 1

pesudo code

let recursiveif expr n outputaction =
  if expr n
  then 
  else recursiveif expr n+1 && n+1 < length(expr)
      


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

[toc] | [next] | [standalone]


#461

FromMark Carroll <mtbc@bcs.org>
Date2016-10-06 08:58 +0100
Message-ID<87r37tgb7m.fsf@ixod.org>
In reply to#460
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

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


#462

FromHo Yeung Lee <davidbenny2000@gmail.com>
Date2016-10-06 01:07 -0700
Message-ID<8594409c-d02f-4bd3-855a-017c3466757c@googlegroups.com>
In reply to#461
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

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


#463

FromMark Carroll <mtbc@bcs.org>
Date2016-10-06 09:53 +0100
Message-ID<87fuo9uadm.fsf@ixod.org>
In reply to#462
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

[toc] | [prev] | [standalone]


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


csiph-web