caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* a question bout exetract a sub-element of element in triple
@ 2009-02-22 21:56 Su Zhang
  2009-02-22 22:04 ` [Caml-list] " Christophe Raffalli
  2009-02-23  9:39 ` Florent Ouchet
  0 siblings, 2 replies; 3+ messages in thread
From: Su Zhang @ 2009-02-22 21:56 UTC (permalink / raw)
  To: caml-list

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

I encountered a new problem which is I want to get " 1 " from a triple
"(0,2,[1,2,3])", which means I want to get the first value of the third item
in one triple and itself is a list, but when I use the List.hd
(third(0,2,[1,2,3])), it will give me the entire list which is [1,2,3]
the definition of the third is "let third(x,y,z)=z", so is there a way I can
get out "1" from "(0,2,[1,2,3])"? if possible, would you please give me some
advices?

thank you very much

-- 
Su Zhang

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

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

* Re: [Caml-list] a question bout exetract a sub-element of element in triple
  2009-02-22 21:56 a question bout exetract a sub-element of element in triple Su Zhang
@ 2009-02-22 22:04 ` Christophe Raffalli
  2009-02-23  9:39 ` Florent Ouchet
  1 sibling, 0 replies; 3+ messages in thread
From: Christophe Raffalli @ 2009-02-22 22:04 UTC (permalink / raw)
  To: Su Zhang; +Cc: caml-list


[-- Attachment #1.1: Type: text/plain, Size: 1554 bytes --]

Su Zhang a écrit :
> I encountered a new problem which is I want to get " 1 " from a triple
> "(0,2,[1,2,3])", which means I want to get the first value of the
> third item in one triple and itself is a list, but when I use the
> List.hd (third(0,2,[1,2,3])), it will give me the entire list which is
> [1,2,3]
> the definition of the third is "let third(x,y,z)=z", so is there a way
> I can get out "1" from "(0,2,[1,2,3])"? if possible, would you please
> give me some advices?
>  
> thank you very much
List.hd (third(0,2,[1;2;3])) ?

[1,2,3], is a one element list ...

Cheers,
Christophe

>
> -- 
> Su Zhang
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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
>   


-- 
Christophe Raffalli
Universite de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tel: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution 
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------


[-- Attachment #1.2: Christophe_Raffalli.vcf --]
[-- Type: text/x-vcard, Size: 310 bytes --]

begin:vcard
fn:Christophe Raffalli
n:Raffalli;Christophe
org:LAMA (UMR 5127)
email;internet:christophe.raffalli@univ-savoie.fr
title;quoted-printable:Ma=C3=AEtre de conf=C3=A9rences
tel;work:+33 4 79 75 81 03
note:http://www.lama.univ-savoie.fr/~raffalli
x-mozilla-html:TRUE
version:2.1
end:vcard


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

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

* Re: [Caml-list] a question bout exetract a sub-element of element in triple
  2009-02-22 21:56 a question bout exetract a sub-element of element in triple Su Zhang
  2009-02-22 22:04 ` [Caml-list] " Christophe Raffalli
@ 2009-02-23  9:39 ` Florent Ouchet
  1 sibling, 0 replies; 3+ messages in thread
From: Florent Ouchet @ 2009-02-23  9:39 UTC (permalink / raw)
  To: Su Zhang, caml-list

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

Su Zhang a écrit :
> I encountered a new problem which is I want to get " 1 " from a triple 
> "(0,2,[1,2,3])", which means I want to get the first value of the 
> third item in one triple and itself is a list, but when I use the 
> List.hd (third(0,2,[1,2,3])), it will give me the entire list which is 
> [1,2,3]
> the definition of the third is "let third(x,y,z)=z", so is there a way 
> I can get out "1" from "(0,2,[1,2,3])"? if possible, would you please 
> give me some advices?
Hi,

[1,2,3] is equivalent to [(1,2,3)], which means "a list containing one 
element whose type is (int*int*int)".
first (List.hd (third(0,2,[1,2,3]))) = 1

[1;2;3] denotes a list of three integer elements.
List.hd (third(0,2,[1;2;3])) = 1

As said in a reply to your previous message, you'll get more complete 
answers by posting to this more suited group: 
http://groups.yahoo.com/group/ocaml_beginners

Cheers,

Florent


[-- Attachment #2: florent.ouchet.vcf --]
[-- Type: text/x-vcard, Size: 309 bytes --]

begin:vcard
fn:Florent Ouchet
n:Ouchet;Florent
org:;CIS/VDS
adr;quoted-printable:46, avenue F=C3=A9lix Viallet,;;TIMA Laboratory - T131;GRENOBLE Cedex;;38031;France
email;internet:florent.ouchet@imag.fr
title:PhD student
tel;work:0476574872
x-mozilla-html:FALSE
url:http://tima.imag.fr
version:2.1
end:vcard


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

end of thread, other threads:[~2009-02-23  9:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-22 21:56 a question bout exetract a sub-element of element in triple Su Zhang
2009-02-22 22:04 ` [Caml-list] " Christophe Raffalli
2009-02-23  9:39 ` Florent Ouchet

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).