How to Teach Difference Lists?

نویسنده

  • Ulrich Geske
چکیده

Lists are, on the one hand, a useful modeling construct in logic programming because of their not predefined length, on the other hand the concatenation of lists by append(L1,L2,L3) is rather inefficient because it copies the list L1. To avoid the invocation of the append/3-procedure an alternative possibility is the use of incomplete lists of the form [ el1, ... elk | Var], in which Var describes a remainder of the list not specified completely. If there is an assignment of a concrete list L for this variable in the program, it will results an efficient (physical) concatenation of the first list elements with L without copying the elements el1,...elk. This physical concatenation does not consist in an (extra-logically) replacing of a pointer (a memory address) but is a purely logical operation since the reference to the list L was already created by the specification in the program. From the mathematical point of view, the difference of the two lists [el1, ...elk | Var] and Var denotes the initial piece [el1, ..., elk] of the complete list. E.g., the difference [1,2,3] arises from the lists [1,2,3| X ] and X or from [1,2,3,4,5] and [4.5] or [ 1,2,3,a] from [1,2,3,a] and [a]. The first-mentioned possibility is the most general representation of the list difference [1,2,3]. Every list may be represented as a difference list. The empty list can be expressed as a difference of the two lists L and L, the list List is the difference of the list List and the empty list. The combination of the two list components [el1, ...elk | Var] and Var in a structure with the semantics of the list difference will be denoted as a “difference list”. Since such a combination is based on the possibility of specifying incomplete lists, the Prolog standard does not provide any standard notation for this. A specification of a difference list from the two lists L and R may be given, by a list notation [L, R] or by the use of a separator, e.g. L−R or L\R (the used separator must be defined in the concrete Prolog system) or as two separate arguments separated by commas in the argument list. Unfortunately, in programs the concatenation is very frequently expressed using a call of the append/3 procedure. The reason for it may be the inadequate explanation of the use of incomplete lists and the difference list technique using such incomplete lists. Very different types of the representations of difference lists and very different attitudes to them can befound in well–known manuals and textbooks about Prolog. On the one hand, Clocksin has described this technique in a tutorial [4] based on his book “Clause and Effect” [3] as “probably one of the most ingenious programming techniques ever invented yet neglected by mainstream computer science”. On the other hand, Dodds [10] opinion concerning a pair of variables for the result of a list operation and the used accumulator, like (All, Temp), is: “some people find it helpful to think of All and Temp as a special data structure called difference list. We prefer to rest our account of the matter on the logical reading of the variable as referring to any possible tail, rather than to speak of lists with variable tails ”, which can be read in his textbook “Prolog. A Logical Approach”. In this paper, a detailed summary of the presentations to difference lists and related topics (accumulator technique) in the literature is given. One frequent problem with the list concatenation by append/3 consists in invocations of append/3 after the recursive procedure call. We will demonstrate, how such left–recursive procedures can be transformed into right–recursion using the folding–/unfolding technique. In the sequel, we will consider different ways for realization of append-free concatenations of programs. The different techniques which are essential for the list

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Comparison of the effect of teach-back method and video clip teaching on the sense of coherence of mothers with children suffering from asthma

Aims: The aim of this study was to compare the effect of teach-back method and video clip teaching on the sense of coherence of mothers with children suffering from asthma. Materials & Methods: In this field trial study 75 eligible mothers with children suffering from asthma were selected by convenience sampling method, but were randomly divided into three groups of: video clip group, teach-ba...

متن کامل

How to teach English with Technology

320 ISSN 1436-4522 (online) and 1176-3647 (print). © International Forum of Educational Technology & Society (IFETS). The authors and the forum jointly retain the copyright of the articles. Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage ...

متن کامل

English Vocabulary for Equine Veterans: How Different from GSL and AWL Words

ESP students are usually suggested to master general and academic word lists such as Wests’ (1953) General Service List (GSL) and Coxhead’s (2000) Academic Word List (AWL) to be able to read their academic texts. However, it seems that university students may not need to learn all the words in the two lists as some words in the lists are of less frequency in academic texts. Moreover, there are ...

متن کامل

Comparison of the Effect of Two Teach-Back Training and Pictorial Training Methods on Medication Adherence in Heart Failure Patients

Background & Aim: Medicinal nonadherence prevents the achievement of therapeutic goals in cardiovascular patients. Training is essential to increase medicinal adherence. Therefore, the present study compared the effect of two teach-back and pictorial training methods on the medication adherence in heart failure patients. Methods: This quasi-experimental study was performed on 210 heart failure...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2006