功能和列表在计划/球拍 [英] functions and lists in scheme/racket

查看:115
本文介绍了功能和列表在计划/球拍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何定义一个带有一个参数的函数,它应该是一个列表,并返回
列表中的元素,它们本身就是列表?

<$ ($)$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $


解决方案

通过一个列表?



与原始相同的一个简单的问题是这样的:设计一个函数,它需要一个数字列表,并只保留偶数。你能做到这一点吗?



看看 http://www.ccs.neu.edu/home/matthias/HtDP2e/htdp2e-part2.html 并且通过其指导练习也可能有所帮助。


How would you define a function which takes one argument, which should be a list, and returns the elements in the list which are themselves lists?

(check-expect (find-sublists ’(1 2 () (3) (a b c) a b c)) 
              ’(() (3) (a b c)))

解决方案

Do you have experience designing functions that can filter through a list?

A simpler problem with the same flavor as the original is something like this: design a function that takes a list of numbers and keeps only the even numbers. Would you be able to do that function?

Looking at http://www.ccs.neu.edu/home/matthias/HtDP2e/htdp2e-part2.html and going through its guided exercises may also help.

这篇关于功能和列表在计划/球拍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆