<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/10/2133e8c023983b75e9eaac3726dd6ed9"
  from="Brian Hurt &lt;bhurt@s...&gt;"
  author="Brian Hurt"
  date="2003-10-23T19:32:27"
  subject="Re: [Caml-list] actualize a string"
  prev="2003/10/e7f6c0d5605db8954852475f246f1109"
  next="2003/10/2e8a6962baf66f1c24c5f132e0e4d98a"
  prev-in-thread="2003/10/31fc9734cb77074b2b1b48ffdc5de321"
  prev-thread="2003/10/e3a4825e2cfa9c175bbf57ff30c4ac42"
  next-thread="2003/10/e7f6c0d5605db8954852475f246f1109"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] actualize a string">
<msg 
  url="2003/10/31fc9734cb77074b2b1b48ffdc5de321"
  from="Flavio Leonardo Cavalcanti de Moura &lt;flavio@m...&gt;"
  author="Flavio Leonardo Cavalcanti de Moura"
  date="2003-10-23T17:39:29"
  subject="[Caml-list] actualize a string">
<msg 
  url="2003/10/2133e8c023983b75e9eaac3726dd6ed9"
  from="Brian Hurt &lt;bhurt@s...&gt;"
  author="Brian Hurt"
  date="2003-10-23T19:32:27"
  subject="Re: [Caml-list] actualize a string">
</msg>
</msg>
</thread>

<contents>
On Thu, 23 Oct 2003, Flavio Leonardo Cavalcanti de Moura wrote:

&gt; 	I am trying to build a procedure such that some reductions are
&gt; performed while a list (of redex) is not empty. The problem is that a
&gt; new list is needed at each step otherwise it will loop for ever. The
&gt; actual code is
&gt; 
&gt; let normal exp =
&gt;  let l = exp :: [] in
&gt;  while (matchingApp exp [] []) &lt;&gt; [] do
&gt;        exp := (appreduction exp (hd (matchingApp exp [] [])));
&gt;        exp :: l done; l;;
&gt; 
&gt; After the 'while' I would like to actualize the expression 'exp' with the
&gt; string (appreduction exp (hd (matchingApp exp [] []))). The problem is
&gt; that with := it does not work. How can I do that? I couldn't find anything
&gt; in the ocaml manual.

I'm not 100% sure what you're trying to do here.  Applying a function to 
every member of a list is easy- look at List.iter and List.fold_left.  
fold_left is especially useful for "accumulating" a result over the list.

I think what you want to do is:

let normal exp = 
	let f l x = 
		match l with
			| [] -&gt; assert false
			| h :: t -&gt; (appreduction h x) :: t
	in
	List.fold_left f [ exp ] (matchingApp exp [] [])
;;

but I'm not sure.

Give me a clue: what are the types of matchingApp and appreduction?

Brian


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

