[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

#### 2.7.13.2 Filter

Another well known list operation is that which applies a predicate to every item of a list, and deletes those for which the predicate is false. For a predicate with virtual code `p`, such an application can be coded conveniently in this form,

T23

  [[`filter`]] `p` = `((nil,nil),(nil,(p,nil)))`

which is to say that writing `((nil,nil),(nil,(p,nil)))` in `silly` is the same as writing `filter p`.

The virtual machine detects code of this form provided that `p` is other than `nil`, and evaluates it consistently with the following properties, causing it to have the meaning that it does.

P26

  ([[`filter`]] `p`) `nil` = `nil`

P27

  ([[`filter`]] `p`) `(x,y)` = ([[`filter`]] `p`) `y` if `p `x`` = `nil`

P28

  ([[`filter`]] `p`) `(x,y)` = `(x,`([[`filter`]] `p`) `y)` if `p x` is a non-`nil` tree

This document was generated on November 8, 2012 using texi2html 1.82.