From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA26487; Wed, 14 Feb 2001 18:34:12 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA26490 for ; Wed, 14 Feb 2001 18:34:11 +0100 (MET) Received: from mailgw1.fhg.de (mailgw1.fhg.de [153.96.1.2]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f1EHYBb11692 for ; Wed, 14 Feb 2001 18:34:11 +0100 (MET) Received: from ilt.fhg.de (ilt.ilt.fhg.de [153.96.180.2]) by mailgw1.fhg.de (8.11.1/8.11.1) with ESMTP id f1EHY6F16685; Wed, 14 Feb 2001 18:34:06 +0100 (MET) Received: from eent230 (eelta136.llt.RWTH-Aachen.DE [137.226.47.136]) by ilt.fhg.de (8.9.3/8.9.3) with SMTP id SAA08358; Wed, 14 Feb 2001 18:34:04 +0100 (MET) Message-Id: <200102141734.SAA08358@ilt.fhg.de> From: wester@ilt.fhg.de To: maulin shah Date: Wed, 14 Feb 2001 18:34:05 +0100 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: [Caml-list] stack CC: caml-list@inria.fr In-reply-to: <20010213222451.40437.qmail@web12202.mail.yahoo.com> X-mailer: Pegasus Mail for Win32 (v3.01d) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > hi all, > I am a student and learning ocaml. need help for one > problem of Unbound value stack > here is my code. > > type ins =PUSH of float| IADD|ISUB;; > type stack = ins list;; > type opn = Add|Sub;; > type exp = Num of float | Opn of exp* opn *exp;; > > let rec compile exp= > match exp with > Num x-> (PUSH x)::stack > |Opn e1,Add,e2 -> compile e2, > compile e1, > (IADD)::stack;; > > gives error : unbound value stack???? > could any one clrify this??? > I'm an OCaml beginner too but I hope this is what you wanted. (Any other solutions?) type ins = PUSH of float | IADD | ISUB;; type stack = ins list;; type opn = Add|Sub;; type exp = Num of float | Opn of exp * opn * exp;; let rec compile exp = match exp with Num x -> (PUSH x)::[] | Opn (e1,Add,e2) -> List.append (List.append (compile e1) (compile e2)) (IADD::[]); | Opn (e1,Sub,e2) -> List.append (List.append (compile e1) (compile e2)) (ISUB::[]);; let m = Opn (Opn (Num 2.0, Sub, Num 3.0), Add, Num 2.0);; let stackn = compile m;; Rolf Wester ------------------------------------- Rolf Wester wester@ilt.fhg.de ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr