Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Francois Colonna <colonna@ccr.jussieu.fr>
To: caml-list@yquem.inria.fr
Subject: no error with ocamlc, a syntax error with ocaml
Date: Fri, 29 Sep 2006 09:54:09 +0200	[thread overview]
Message-ID: <451CD121.3070502@ccr.jussieu.fr> (raw)

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

Hello,

the small ocaml program attached gives no errors at compilation

ocamlc -c tuvuw_from_data_error.ml

and this syntax error at execution:

ocaml < tuvuw_from_data_error.ml
        Objective Caml version 3.09.2

# * *       val s_d1 : string = "1"
# val s_d2 : string = "2"
# val s_d3 : string = "3"
# val s_d4 : string = "4"
# val s_d5 : string = "5"
#     val d1 : int = 1
# val d2 : int = 2
# val d3 : int = 3
# val d4 : int = 4
# val d5 : int = 5
  print_string (" w d5 = ") ;t = <fun>
  print_int (w_from_data ( d5 ) ) ;>
  print_newline () ;t -> int = <fun>
    val t : int * int -> int = <fun>
  print_string (" v d3 d4 d5 = ") ;ta : int -> int = <fun>
  print_int (v_from_data ( d3, d4, d5 ) ) ;= <fun>
  print_newline () ;_data : int * int * int -> int = <fun>
          val t_from_data : int * int * int * int * int -> int = <fun>
  print_string (" u  d1 d2 = ") ;      for data :  d1 = 1 d2 = 2 d3 = 3 
d4 = 4 d5 = 5
  print_int (u_from_data ( d1, d2 ) ) ;
  print_newline () ;3 d4 d5 = 22
    unit = ()
#
Syntax error
#



By the way, why is the output mixed up ?

Thanks
François Colonna

[-- Attachment #2: tuvuw_from_data_error.ml --]
[-- Type: text/plain, Size: 1580 bytes --]

(**
 * trying to implement cascade
 *)


let s_d1 = "1" ;;
let s_d2 = "2" ;;
let s_d3 = "3" ;;
let s_d4 = "4" ;;
let s_d5 = "5" ;;


let d1 = int_of_string (s_d1) ;;
let d2 = int_of_string (s_d2) ;;
let d3 = int_of_string (s_d3) ;;
let d4 = int_of_string (s_d4) ;;
let d5 = int_of_string (s_d5) ;;

(**
 * define functions as function of their sons
 *)

let w (a_a) = a_a + 3 ;;

let u (a_a, b_a) = a_a + b_a + 1;;

let v (a_a, b_a) = a_a + b_a + 2 ;;

let t (a_a, b_a) = a_a + b_a ;;


(** 
 * express each function as a function of its data
 * using the functon of its sons
 *)


let w_from_data ( a_a ) = 
    w ( a_a )  
;;

let u_from_data ( a_a, b_a ) = 
    u ( a_a, b_a ) 
;;

let v_from_data ( a_a, b_a, c_a ) = 
    v ( u_from_data ( a_a, b_a),
        w_from_data ( c_a) ) 
;;

let t_from_data ( a_a, b_a, c_a, d_a, e_a ) = 
    t ( u_from_data (a_a, b_a), 
        v_from_data (c_a, d_a, e_a) ) 
;;

(** 
 * execution 
 *)


print_string (" for data : ") ;
print_string (" d1 = ") ;
print_int d1 ;
print_string (" d2 = ") ;
print_int d2 ;
print_string (" d3 = ") ;
print_int d3 ;
print_string (" d4 = ") ;
print_int d4 ;
print_string (" d5 = ") ;
print_int d5 ;
print_newline () ; 
;;

print_string (" t d1 d2 d3 d4 d5 = ") ;
print_int (t_from_data ( d1, d2, d3, d4, d5 ) ) ;
print_newline () ;
;;

print_string (" w d5 = ") ;
print_int (w_from_data ( d5 ) ) ;
print_newline () ;

print_string (" v d3 d4 d5 = ") ;
print_int (v_from_data ( d3, d4, d5 ) ) ;
print_newline () ;

print_string (" u  d1 d2 = ") ;
print_int (u_from_data ( d1, d2 ) ) ;
print_newline () ;
 

             reply	other threads:[~2006-09-29  7:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-29  7:54 Francois Colonna [this message]
2006-09-29  8:25 ` [Caml-list] " micha
2006-09-29  8:27 ` Jonathan Roewen
2006-09-29  8:40 ` Virgile Prevosto
2006-09-29  9:11   ` Francois Colonna

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=451CD121.3070502@ccr.jussieu.fr \
    --to=colonna@ccr.jussieu.fr \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox