www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - imports and a data structure (any critique welcome)

reply "Jonathan" <jdgall84 gmail.com> writes:
I come from Haskell, so please excuse any functional programming 
idiosyncracies I have :)

In Haskell, I have a datatype for representing so called terms 
which looks like:

     data Term = Var Char | Op Char [Term]

i.e. a Term is a variable (denoted by an Int) or an operation 
(whose name is also denoted by an int), applied to a list of its 
arguments.  For example,

     f(g(x,y),a(),x) is represented by Op 'f' [Op 'g' [Var 'x',Var 
'y'],Op 'a' [], Var 'x]

Now, the reason I am writing in D is twofold.  First, I want to 
learn the D language, and second I really need pointers to reduce 
certain complexities in the operations (Haskell does not have 
observable sharing).
Dec 26 2013
parent reply "TheFlyingFiddle" <kurtyan student.chalmers.se> writes:
On Friday, 27 December 2013 at 00:23:58 UTC, Jonathan wrote:
 I come from Haskell, so please excuse any functional 
 programming idiosyncracies I have :)

 In Haskell, I have a datatype for representing so called terms 
 which looks like:

     data Term = Var Char | Op Char [Term]

 i.e. a Term is a variable (denoted by an Int) or an operation 
 (whose name is also denoted by an int), applied to a list of 
 its arguments.  For example,

     f(g(x,y),a(),x) is represented by Op 'f' [Op 'g' [Var 
 'x',Var 'y'],Op 'a' [], Var 'x]

 Now, the reason I am writing in D is twofold.  First, I want to 
 learn the D language, and second I really need pointers to 
 reduce certain complexities in the operations (Haskell does not 
 have observable sharing).
Could you please clarify the question? I did not understand what you wanted to ask.
Dec 27 2013
parent "TheFlyingFiddle" <kurtyan student.chalmers.se> writes:
Found your other post nwm.
Dec 27 2013