-----Original Message-----
From: libguestfs-bounces(a)redhat.com [mailto:libguestfs-bounces@redhat.com] On
Behalf Of Richard W.M. Jones
Sent: Thursday, May 28, 2015 7:18 PM
To: Pino Toscano
Cc: libguestfs(a)redhat.com
Subject: Re: [Libguestfs] [PATCH v2 02/11] resize: add logical_partitions and
extended_partition
On Thu, May 28, 2015 at 01:13:28PM +0200, Pino Toscano wrote:
> In data giovedì 28 maggio 2015 12:06:18, Richard W.M. Jones ha scritto:
> > > + let logical_partitions =
> > > + List.filter (fun p -> parttype = MBR && p.p_mbr_p_type =
LogicalPartition)
partitions in
> > > + (* Filter out logical partitions. See note above. *)
> > > + let partitions =
> > > + (* for GPT, all partitions are regarded as Primary Partition,
> > > + * e.g. there is no Extended Partition or Logical Partition. *)
> > > + List.filter (fun p -> parttype <> MBR || p.p_mbr_p_type
<> LogicalPartition)
partitions in
> >
> > Although this is code is correct, it is clearer and shorter to write
> > the test using a separate function, so it would become:
> >
> > let is_logical_partition p =
> > parttype = MBR && p.p_mbr_p_type = LogicalPartition
> > in
> > let logical_partitions = List.filter is_logical_partition partitions in
> > let partitions =
> > List.filter (fun p -> not (is_logical_partition p)) partitions in
>
> Or, even better:
>
> let logical_partitions, partitions =
> List.partition is_logical_partition partitions in
Indeed, that is better :-)
Thanks for your comments and hints in Ocaml.
That's what I want to write.
Will fix in v3.
Regards,
- Chen