Version française
Home     About     Download     Resources     Contact us    
Browse thread
Syntactical Array constructor evaluating elements from right to left - Why?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jakob Lichtenberg <jakobl@w...>
Subject: Syntactical Array constructor evaluating elements from right to left - Why?
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