Re: question regarding head and tail of empty list

From: Assaf J. Kfoury (kfoury@cs.bu.edu)
Date: Thu Sep 23 2004 - 13:52:47 EDT


Return-Path: <kfoury@cs.bu.edu>
Received: from cs.bu.edu (cs [128.197.12.2]) by cs3.bu.edu (8.12.11/8.12.11) with ESMTP id i8NHqpbL027992; Thu, 23 Sep 2004 13:52:51 -0400
Received: from cs.bu.edu (kfoury@fiddle [128.197.10.114]) (authenticated bits=0) by cs.bu.edu (8.12.2/8.12.2) with ESMTP id i8NHqpPM026750; Thu, 23 Sep 2004 13:52:51 -0400 (EDT)
Sender: kfoury@cs.bu.edu
Message-ID: <41530D6F.6BC0033D@cs.bu.edu>
Date: Thu, 23 Sep 2004 13:52:47 -0400
From: "Assaf J. Kfoury" <kfoury@cs.bu.edu>
Organization: Boston University
X-Mailer: Mozilla 4.78 [en] (X11; U; SunOS 5.8 sun4u)
X-Accept-Language: en
To: ashwin thangali <tvashwin@cs.bu.edu>, cs520@cs.bu.edu
Subject: Re: question regarding head and tail of empty list
References: <Pine.SOL.4.20.0409231342580.13319-100000@csa.bu.edu>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Spam-HitLevel: 
X-Spam-DCC: SIHOPE-DCC-3: cs3.bu.edu 1085; Body=6 Fuz1=6 Fuz2=6
X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on cs3.bu.edu
X-Spam-Level: 
X-Spam-Status: No, hits=0.0 required=10.0 tests=none autolearn=ham  version=2.64
X-Spam-Pyzor: Reported 0 times.
Status:   
X-Mozilla-Status: 8011
X-Mozilla-Status2: 00000000
X-UIDL: 411f69ec00000b73

Here is a list of 6 integers in the style of programming
language Scheme:

(4 5 1 2 30 40)

Call it L. Then head(L) = 4 which is an integer, and
tail(L) = (5 1 2 30 40) which is a list of integers.

A special case is the empty list ( ). Call it nil. It is a
design decision what to do with head(nil) and tail(nil).
The most common is to make head(nil) and tail(nil)
cause a run-time error.

I hope this helps.

Assaf

ashwin thangali wrote:

> asaf,
>
> is the result of head (or tail) of a list an element or a list? if its
> an element, what does head or tail return for an empty list?
>
> ashwin
>
> Ashwin V. Thangali
> 111 Cummington Street,MCS 263,
> Computer Science Dept,
> Boston University,
> Boston, MA 02215
> Office: 617 358 1139
> Home: 617 734 6209
> Homepage: http://cs-people.bu.edu/tvashwin



This archive was generated by hypermail 2b29 : Fri Nov 19 2004 - 17:00:43 EST