From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id F2FC3820A1 for ; Thu, 5 Sep 2013 19:15:02 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of caseybasichis@gmail.com) identity=pra; client-ip=209.85.220.170; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="caseybasichis@gmail.com"; x-sender="caseybasichis@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of caseybasichis@gmail.com designates 209.85.220.170 as permitted sender) identity=mailfrom; client-ip=209.85.220.170; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="caseybasichis@gmail.com"; x-sender="caseybasichis@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-vc0-f170.google.com) identity=helo; client-ip=209.85.220.170; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="caseybasichis@gmail.com"; x-sender="postmaster@mail-vc0-f170.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjYBAPu6KFLRVdyqm2dsb2JhbABYA4JDeVGvBYNahi+IPIEjCBYOAQEBAQEGCwsJFCiCJAEBBAEnGQEUBx4DAQsGBQcEDQwiIQEBEQEFAQoSBhMICoddAQMJBgycZ4xQgwWENgoZJwMKZIgGAQUMjGiCXBcRhAwDiTWMV4FpgS+LCINGGCmCY4IFHA X-IPAS-Result: AjYBAPu6KFLRVdyqm2dsb2JhbABYA4JDeVGvBYNahi+IPIEjCBYOAQEBAQEGCwsJFCiCJAEBBAEnGQEUBx4DAQsGBQcEDQwiIQEBEQEFAQoSBhMICoddAQMJBgycZ4xQgwWENgoZJwMKZIgGAQUMjGiCXBcRhAwDiTWMV4FpgS+LCINGGCmCY4IFHA X-IronPort-AV: E=Sophos;i="4.90,848,1371074400"; d="scan'208";a="31676384" Received: from mail-vc0-f170.google.com ([209.85.220.170]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 05 Sep 2013 19:15:01 +0200 Received: by mail-vc0-f170.google.com with SMTP id kw10so1404591vcb.1 for ; Thu, 05 Sep 2013 10:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ZuvK5gjvhLptmZyGvNiaanpCMHlczWNoCJG07j+FjxM=; b=qgEwX27KxkC5WLfAiW2iLaBliNCbFhdgXRFgnkI4JDtYM3Auo6bT6SMJ8gZBnj+Z86 CCDBww+/J1+LXroqOXoDD3Sx+QBfw0CLNDTykkAc3kflEZ4pBFxd8/sgsQOrFsCmOgSe UMELy3GP6VlkIubF8eCb/uZU7jb3JtfDLlFdQuKj+TSnq4G27sosRCacbodYz79tYhw+ UYShfM2u22zjSITlMTWblde6yAxUYquM7cQ2H8pWDKn5ETADiQKt8uLQK0fpvhcVc/Mn Nvi7aDqJ5/beZfSAGPyhMH/pgASatYNI7mRke3ONw/mM2Y/jMFX8ivnVsUBdjUUHBMVu 1xig== MIME-Version: 1.0 X-Received: by 10.52.166.71 with SMTP id ze7mr42755vdb.50.1378401300831; Thu, 05 Sep 2013 10:15:00 -0700 (PDT) Received: by 10.52.117.101 with HTTP; Thu, 5 Sep 2013 10:15:00 -0700 (PDT) In-Reply-To: <5228B581.3010903@coherentgraphics.co.uk> References: <5228B581.3010903@coherentgraphics.co.uk> Date: Thu, 5 Sep 2013 10:15:00 -0700 Message-ID: From: Casey Basichis To: OCaml Mailing List Content-Type: multipart/alternative; boundary=001a11c25054e4e62d04e5a60f9a Subject: Re: [Caml-list] Construct a list of records from several lists --001a11c25054e4e62d04e5a60f9a Content-Type: text/plain; charset=ISO-8859-1 Sorry about the confusion. I'm taking from one element from each list per record. The lists can all be arbitrarily long as long as they share the same length. lista = [1; 2; 3; 4; 5; 6; 3] listb = [2; 5; 7; 8; 1; 2; 4] listc = [4; 6; 8; 3; 5; 8; 2] type t = {a : int; b: int; c: int} {a=1; b=2; c=4} {a=2; b=5; c=6} {a=3; b=7; c=8} {a=4; b=8; c=3} ... I will subscribe to the beginners list as well. Thanks, Casey On Thu, Sep 5, 2013 at 9:46 AM, John Whitington wrote: > Hi Casey, > > > Casey Basichis wrote: > >> Hi, >> >> I'm new to Ocaml. >> > > There is also this list, for beginners specifically: > > http://groups.yahoo.com/neo/**groups/ocaml_beginners/info > > > I have five lists of ints, how can I can I combine them into a list of >> records where the fields are filled with values from each of the lists? >> > > Do you mean that the lists are fixed-length, that you have a record type > something like > > type t = {a : int; b : int; c : int; d : int} > > and you want to convert each list, which is something like > > [1; 2; 3; 4] > > into a record something like > > {a = 1; b = 2; c = 3; d = 4} > > ? > > > In which case, you want to use pattern matching to write a function of type > > int list -> t > > which converts a (fixed-length) list to a thing of type t and then you can > use List.map to deal with all your lists, producing a t list from an int > list list. > > If you meant something different entirely, please clarify! > > With Thanks, > > -- > John Whitington > Director, Coherent Graphics Ltd > http://www.coherentpdf.com/ > > -- Casey James Basichis Composer - Adventure Time - Cartoon Network http://www.caseyjamesbasichis.com caseybasichis@gmail.com 310.387.7540 --001a11c25054e4e62d04e5a60f9a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Sorry about the confusion. I'm taking from one element = from each list per record. The lists can all be arbitrarily long as long as= they share the same length. =A0

lista =3D [1; 2; 3; 4;= 5; 6; 3]
l= istb =3D [2; 5; 7; 8; 1; 2; 4]
listc =3D [4; 6;= 8; 3; 5; 8; 2]

type t =3D {a : int; b: int; c: int}<= /div>

= {a=3D1; b=3D2; c=3D4}
{a=3D2; b=3D5; c=3D6}
{a=3D3; b=3D7; c=3D8}
{a=3D4; b=3D8; c=3D3}
...

I will= subscribe to the beginners list as well.

Thanks,
Casey
--001a11c25054e4e62d04e5a60f9a--