From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=DNS_FROM_RFC_POST,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 1275BBBAF for ; Mon, 9 Mar 2009 14:19:48 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuQCAJq0tEnRVduukWdsb2JhbACMcYd8QQEBCQkMBw+tEYEHjR0BAwEDhAIGgxM X-IronPort-AV: E=Sophos;i="4.38,329,1233529200"; d="scan'208";a="36287514" Received: from mail-ew0-f174.google.com ([209.85.219.174]) by mail4-smtp-sop.national.inria.fr with ESMTP; 09 Mar 2009 14:19:34 +0100 Received: by ewy22 with SMTP id 22so1089266ewy.27 for ; Mon, 09 Mar 2009 06:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=jQtdSzp9qcS0QtAouZ4bTIYjNruNQjMWxpqYGlVPvY8=; b=m96l1Jh6r7JtfX76mDPvEE+q49+wxwMRjB1HFMmdh/DErXNmJAhm2wQTTyVxZWfWuq u0OkCJPV3/iNvRhxpmNF3ETZZg1t8n17XYEoqIX/RGEMxn9ZVoCcjeM4slaZxlBoN/fu D+pW7or6YST4uWiVCwap1+UE7rR9D3ALeRpVM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=SBKgroJGtngjC0d1dkwKJX5YSO/hAQuhb/hfEHQjM40kjYdBanHUotHLBvNWeEtTv8 UwFa5lpbull1N/SwFyABWLHSDQqN163Xd/T9817ymXUvb6K+Hij5Pplx6yJNjFJ8dTt4 cGSTQ7ro/eapya0WVPT5OemmLYEUO8sW8Tdgk= Received: by 10.216.47.71 with SMTP id s49mr2086798web.72.1236604772535; Mon, 09 Mar 2009 06:19:32 -0700 (PDT) Received: from ?192.168.1.10? (AMontsouris-159-1-28-247.w90-46.abo.wanadoo.fr [90.46.235.247]) by mx.google.com with ESMTPS id 32sm7532053nfu.58.2009.03.09.06.19.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 09 Mar 2009 06:19:32 -0700 (PDT) Message-ID: <49B51619.9010306@lri.fr> Date: Mon, 09 Mar 2009 14:14:01 +0100 From: AUGER Cedric User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: David Rajchenbach-Teller Cc: Su Zhang , caml-list@yquem.inria.fr Subject: Re: [Caml-list] how can I express empty element? References: <1236603817.18569.4.camel@Blefuscu> In-Reply-To: <1236603817.18569.4.camel@Blefuscu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; cheers:01 ocaml:01 beginner's:01 ocaml:01 bug:01 2009:98 beginners:01 wrote:01 wrote:01 caml-list:01 caml-list:01 constructor:01 bin:01 define:02 caml:02 David Rajchenbach-Teller wrote: > No, that's not possible. :: is an algebraic constructor, which means, > among other things, that it accepts no neutral element (well, except > when the list is infinite, but that's probably not what you're looking > for). > And even if the list is infinite, I don't see any way to do it; but you can always define: let cons2 a l = match a with | Some x -> x::l | None -> l and then use cons2 instead of :: the neutral element is then 'None', that is cons2 None l = l. And you can't do []::l excepted if l is a list of lists. (And even so, []::l is not l!) I don't see why one can want to have a "neutral" element in list, since it could mess a with pattern matching: [] should be match as well with [] than with neutre::[] > Cheers, > David > > On Sun, 2009-03-08 at 22:59 -0500, Su Zhang wrote: > >> Hi all, >> >> I have a question on ocaml, is there a way to write a empty element >> say a which can make a::ax=ax ? I tried to find out in library, yet I >> didn't get the right way out, and it doesn't work if I make a=[], so >> do you know whether there is a technique can realize this function? >> I've got stuck on this point for a very long time. >> >> thanks >> >> -- >> Su Zhang >> PHD Student >> Computer Information and Science >> Kansas State University >> >> _______________________________________________ >> 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 >>