caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Syntactical Array constructor evaluating elements from right to left - Why?
@ 2007-09-19 17:32 Jakob Lichtenberg
  2007-09-19 18:16 ` [Caml-list] " Jon Harrop
  0 siblings, 1 reply; 2+ messages in thread
From: Jakob Lichtenberg @ 2007-09-19 17:32 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 365 bytes --]

Why is the syntactical array constructor [| ... |] evaluating  elements
from right to left:

 

# let f i = (Printf.printf "%d\n" i; i);;

val f : int -> int = <fun>

 

# Array.init 3 f;;

0

1

2

- : int array = [|0; 1; 2|]

 

# [| f 0 ; f 1; f 2|];;

2

1

0

- : int array = [|0; 1; 2|]

 

Thanks,

 

- Jakob 

 


[-- Attachment #2: Type: text/html, Size: 5509 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Syntactical Array constructor evaluating elements from right to left - Why?
  2007-09-19 17:32 Syntactical Array constructor evaluating elements from right to left - Why? Jakob Lichtenberg
@ 2007-09-19 18:16 ` Jon Harrop
  0 siblings, 0 replies; 2+ messages in thread
From: Jon Harrop @ 2007-09-19 18:16 UTC (permalink / raw)
  To: caml-list

On Wednesday 19 September 2007 18:32:18 Jakob Lichtenberg wrote:
> Why is the syntactical array constructor [| ... |] evaluating  elements
> from right to left:

Evaluation order is undefined in OCaml.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists/?e


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-09-19 18:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-19 17:32 Syntactical Array constructor evaluating elements from right to left - Why? Jakob Lichtenberg
2007-09-19 18:16 ` [Caml-list] " Jon Harrop

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).