Loading ...
Sorry, an error occurred while loading the content.
 

List.split to get two lists (as a pair of lists) from one list (as a list of pairs)

Expand Messages
  • stalkern2
    Hello everybody I ve found a nice function it s called List.split, and it s ready to use for problems like the one proposed by Johan some postings ago. # let
    Message 1 of 2 , Mar 5, 2002
      Hello everybody
      I've found a nice function it's called List.split, and it's ready to use for
      problems like the one proposed by Johan some postings ago.

      # let lys = [("FHARGA","fharga.sun.ac.za"); ("HUMARGA","humarga.sun.ac.za");
      ("NARGA","narga.sun.ac.za"); ("RENET","renet.sun.ac.za");
      ("SUN_ADM","adm.sun.ac.za");
      ("SUN_AKAD","akad.sun.ac.za"); ("SUN_BIT","bit.sun.ac.za");
      ("SUN_FIRGA","firga.sun.ac.za"); ("SUN_HYLL","hyll.sun.ac.za");
      ("SUN_ING","ing.sun.ac.za"); ("SUN_ITBACKUP","itbackup.sun.ac.za");
      ("SUN_SMED","smed.sun.ac.za"); ("SUN_TYG","gerga.sun.ac.za");
      ("SUN_WAT","wat.sun.ac.za")];;
      val lys : (string * string) list =
      [("FHARGA", "fharga.sun.ac.za"); ("HUMARGA", "humarga.sun.ac.za");
      ("NARGA", "narga.sun.ac.za"); ("RENET", "renet.sun.ac.za");
      ("SUN_ADM", "adm.sun.ac.za"); ("SUN_AKAD", "akad.sun.ac.za");
      ("SUN_BIT", "bit.sun.ac.za"); ("SUN_FIRGA", "firga.sun.ac.za");
      ("SUN_HYLL", "hyll.sun.ac.za"); ("SUN_ING", "ing.sun.ac.za");
      ("SUN_ITBACKUP", "itbackup.sun.ac.za"); ("SUN_SMED", "smed.sun.ac.za");
      ("SUN_TYG", "gerga.sun.ac.za"); ("SUN_WAT", "wat.sun.ac.za")]
      # List.split lys;;
      - : string list * string list =
      ["FHARGA"; "HUMARGA"; "NARGA"; "RENET"; "SUN_ADM"; "SUN_AKAD"; "SUN_BIT";
      "SUN_FIRGA"; "SUN_HYLL"; "SUN_ING"; "SUN_ITBACKUP"; "SUN_SMED"; "SUN_TYG";
      "SUN_WAT"],
      ["fharga.sun.ac.za"; "humarga.sun.ac.za"; "narga.sun.ac.za";
      "renet.sun.ac.za"; "adm.sun.ac.za"; "akad.sun.ac.za"; "bit.sun.ac.za";
      "firga.sun.ac.za"; "hyll.sun.ac.za"; "ing.sun.ac.za"; "itbackup.sun.ac.za";
      "smed.sun.ac.za"; "gerga.sun.ac.za"; "wat.sun.ac.za"]

      It is not tail-recursive (that is, it's clumsier than a tail-recursive
      equivalent)

      Bye
      Ernesto
    • stalkern2
      Of course Rémi had already pointed that out, I see. Well! Learning is based upon repeating also... :-) Say that I wanted to say that List.split is nice
      Message 2 of 2 , Mar 5, 2002
        Of course Rémi had already pointed that out, I see. Well! Learning is based
        upon repeating also... :-) Say that I wanted to say that List.split is "nice"
        (Rémi didn't say so) ;-))

        Ernesto

        Alle ore 11:11, martedì 05 marzo 2002, stalkern2 ha scritto:
        > Hello everybody
        > I've found a nice function it's called List.split, and it's ready to use
        > for
      Your message has been successfully submitted and would be delivered to recipients shortly.