Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 软件时空 > 软件相关 > filter 与 mapcar
【标  题】:filter 与 mapcar
【关键字】:filter,mapcar
【来  源】:http://www.cublog.cn/u/4614/showart.php?id=92786

filter 与 mapcar

Your Ad Here     mapcar 和 filter 都是clisp中的高阶函数。lisp的函数可以以其他函数作为参数或者返回值,是程序抽象的重要工具。

CL-USER 1 > (mapcar #'1+ '(1 2 3 4))
(2 3 4 5)

CL-USER 2 > (defun double(x)(* x 2))
DOUBLE

CL-USER 3 > (mapcar #'double '(1 2 3 4))
(2 4 6 8)

filter 的例子:
(defun filter (list-of-elements test)
  (cond ((null list-of-elements) nil)
        ((funcall test (car list-of-elements))
         (cons (car list-of-elements)(filter (cdr list-of-elements) test)))
        (t (filter (cdr list-of-elements) test))))
FILTER

(filter '(1 3 5 4 10) #'evenp)
(4 10)


约瑟夫环的问题(Joseph Ring):【上一篇】
阿蒙的技术面试:【下一篇】
【相关文章】
  • BSD下IPFilter.txt
  • 一个基于netfilter架构的简单防火墙
  • Netfilter中对FTP连线跟踪的处理
  • 防火墙PKTFilter的使用方法
  • ado 记录集对象的filter属性使用中需注意的地方
  • acegi扩展AbstractFilterInvocationDefinitionSource
  • A note to file system filter implementers
  • hdr lighting step 2 - bright pass filter
  • 檔案篩選Filter屬性, 單一索引最大限制
  • ProxSMTP: An SMTP Filter
  • 【随机文章】
  • 珍惜系统盘的空间 10条措施优化系统盘
  • 男性不孕不育,找美国康本就对了!
  • 1400033228",,0,,0 1655,1,0,"声音与字的同步问题怎么解
  • 蠕虫病毒Worm_Funny.A分析报告(2)
  • 使用RewritePath方法实现【不同路径+任意URL后缀重写到指定页面且URL地址不变】(附源码)_AX
  • 设计模式学习整理之创建型模式
  • 为ListView添加ColumnReordered事件(Windows Form)
  • Linux 的中文化问题简介
  • 自动颜色变换<1>
  • 获得文本框的文件名
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.