* Hello
@ 2006-03-14 1:21 Troy Spier
2006-03-14 1:26 ` [Caml-list] Hello Jonathan Roewen
2006-03-14 1:29 ` Jonathan Roewen
0 siblings, 2 replies; 8+ messages in thread
From: Troy Spier @ 2006-03-14 1:21 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 529 bytes --]
Hello! I just read a page on the OCaml website about submitting questions. Well, I have a question for you. How would I put the user input into a text file, that can be read and modified? Let's say I used this function for the input, how would I create a text file of it:
print_string "What's your name ? "; let name = read_line () in Printf.printf "Hello, %s.\n" name ;;
Thank you for all your help.
- Troy
---------------------------------
Yahoo! Mail
Use Photomail to share photos without annoying attachments.
[-- Attachment #2: Type: text/html, Size: 634 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Hello
2006-03-14 1:21 Hello Troy Spier
@ 2006-03-14 1:26 ` Jonathan Roewen
2006-03-14 1:29 ` Jonathan Roewen
1 sibling, 0 replies; 8+ messages in thread
From: Jonathan Roewen @ 2006-03-14 1:26 UTC (permalink / raw)
To: Troy Spier; +Cc: caml-list
> print_string "What's your name ? "; let name = read_line () in Printf.printf
> "Hello, %s.\n" name ;;
let o = open_out "filename";;
output_string o name;;
close_out o;;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Hello
2006-03-14 1:21 Hello Troy Spier
2006-03-14 1:26 ` [Caml-list] Hello Jonathan Roewen
@ 2006-03-14 1:29 ` Jonathan Roewen
2006-03-14 1:35 ` Corey O'Connor
1 sibling, 1 reply; 8+ messages in thread
From: Jonathan Roewen @ 2006-03-14 1:29 UTC (permalink / raw)
To: Troy Spier; +Cc: caml-list
Actually, I should've just linked you to the standard library
documentation (http://caml.inria.fr/pub/docs/manual-ocaml/libref/index.html).
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Hello
2006-03-14 1:29 ` Jonathan Roewen
@ 2006-03-14 1:35 ` Corey O'Connor
0 siblings, 0 replies; 8+ messages in thread
From: Corey O'Connor @ 2006-03-14 1:35 UTC (permalink / raw)
To: Jonathan Roewen; +Cc: Troy Spier, caml-list
The beginners list is a good place to ask these sorts of questions:
http://groups.yahoo.com/group/ocaml_beginners
-Corey
On 3/13/06, Jonathan Roewen <jonathan.roewen@gmail.com> wrote:
> Actually, I should've just linked you to the standard library
> documentation (http://caml.inria.fr/pub/docs/manual-ocaml/libref/index.html).
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
-Corey O'Connor
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Hello
@ 2006-03-14 8:57 yoann padioleau
0 siblings, 0 replies; 8+ messages in thread
From: yoann padioleau @ 2006-03-14 8:57 UTC (permalink / raw)
To: Jonathan Roewen, Troy Spier; +Cc: caml-list
>
> > print_string "What's your name ? "; let name = read_line () in Printf.printf
> > "Hello, %s.\n" name ;;
>
> let o = open_out "filename";;
> output_string o name;;
> close_out o;;
A better (advanced) way is to do it the Lisp way:
with_open_outfile "filename" (fun chan ->
output_string chan name
);
where with_open_outfile is defined by:
let with_open_outfile filename f =
let chan = open_out filename in
let res = f chan in
begin
close_out chan;
res
end
Everywhere where 2 functions must be balanced (here open and close), it is cleaner to introduce
a single higher-order function to enforce such a protocol.
You can also use a function unwind_protect (again invented by the Lisp folk I think)
to also automagically close the channel when f raise an exception.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Caml-list] Hello
@ 2004-01-28 10:53 bgadil
0 siblings, 0 replies; 8+ messages in thread
From: bgadil @ 2004-01-28 10:53 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 101 bytes --]
The message cannot be represented in 7-bit ASCII encoding and has been sent as a binary attachment.
[-- Attachment #2: readme.zip --]
[-- Type: application/octet-stream, Size: 22646 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Caml-list] Hello
@ 2004-01-28 10:01 varesenews
0 siblings, 0 replies; 8+ messages in thread
From: varesenews @ 2004-01-28 10:01 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 83 bytes --]
The message contains Unicode characters and has been sent as a binary attachment.
[-- Attachment #2: body.zip --]
[-- Type: application/octet-stream, Size: 22790 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Caml-list] Hello
@ 2004-01-27 10:36 bessam.abdulrazak
0 siblings, 0 replies; 8+ messages in thread
From: bessam.abdulrazak @ 2004-01-27 10:36 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 83 bytes --]
The message contains Unicode characters and has been sent as a binary attachment.
[-- Attachment #2: document.zip --]
[-- Type: application/octet-stream, Size: 22650 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-03-14 8:57 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-14 1:21 Hello Troy Spier
2006-03-14 1:26 ` [Caml-list] Hello Jonathan Roewen
2006-03-14 1:29 ` Jonathan Roewen
2006-03-14 1:35 ` Corey O'Connor
-- strict thread matches above, loose matches on Subject: below --
2006-03-14 8:57 yoann padioleau
2004-01-28 10:53 bgadil
2004-01-28 10:01 varesenews
2004-01-27 10:36 bessam.abdulrazak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox