From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id GAA12035; Fri, 18 Apr 2003 06:09:34 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id GAA11033 for ; Fri, 18 Apr 2003 06:09:33 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from www.duonix.com ([210.113.163.221]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h3I49U912068 for ; Fri, 18 Apr 2003 06:09:31 +0200 (MET DST) Received: from hama ([192.168.0.254]) by www.duonix.com (8.12.8/8.11.6) with SMTP id h3I4FEvu036310; Fri, 18 Apr 2003 13:15:14 +0900 (KST) (envelope-from shoh@duonix.com) Message-ID: <006f01c30560$48994770$fe00a8c0@hama> From: "SooHyoung Oh" To: , References: <3e9f701f.1227.4928@gis.net> Subject: Re: [Caml-list] Clarification on some ocaml stuff Date: Fri, 18 Apr 2003 13:09:18 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset="ks_c_5601-1987" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam: no; 0.00; caml-list:01 gis:99 confuses:01 experimented:01 figuring:01 bug:01 faq:01 beginner's:01 beginners:01 arrays:01 bin:01 caml-bugs:01 semantics:01 ocaml:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk "group' n rest" is returning 'a array list, not 'a array array. firstN: int -> 'a array -> 'a array * 'a array group': int -> 'a array -> 'a array list group: int -> 'a array -> 'a array array --- SooHyoung Oh ----- Original Message ----- From: "Ryan Bastic" To: Sent: Friday, April 18, 2003 12:25 PM Subject: [Caml-list] Clarification on some ocaml stuff > Hello all, > A few weeks ago I posted a message asking how to create a program in > OCaml to shuffle vector of strings into an array of arrays. Had some > problems understanding how to do it in Ocaml properly, and a kind soul > posted a very elegant solution to the problem :-) unfortunately, i still > can't understand some things from it. > > What follows is some code with comments on how it is expected to be > used, and also > where my confusion in the semantics of the code lay. > > (* Return first 'n' from input and the rest. *) > let firstN n input = > let nInput = Array.length input in > if n >= nInput > then (input, [||]) > else (Array.sub input 0 n, Array.sub input n (nInput - n)) > > let group n input = > let rec group' n input = > if Array.length input = 0 then [] > else > let (front, rest) = firstN n input in > (* the next line confuses me. i'm aware of :: being a list > concatenation > operator, but in this case, shouldn't group 'n rest be > returning an array, > because that's what firstN returns. I've experimented in the > REPL and had > no luck in figuring it out. *) > front :: group' n rest > in > Array.of_list (group' n input) > > if you pop this into the toplevel, and do: > > group 2 [|"Name1"; "Name2"; "Name3"; "Name4"; "Name5";|];; > > you'll see the general functionality expected. > > thanks for any help, > -Ryan > http://malander.undrgnd.net > > ------------------- > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners