scheme的split实现
再chez中并未找到一个split函数,基于尾递归,自己实现了了一个用于字符串拆分的split。
(define split
(lambda (str sep)
(define loop
(lambda (str sep result)
(let ((l_str (string-length str))
(l_sep (string-length sep)))
(cond
((< l_str l_sep) (cons (string-append (car result) (substring str 0 1) ) (cdr result)))
((= l_str l_sep)
(cond
((string=? (substring str 0 l_sep) sep) result)
(else
(cons
(string-append (car result) (substring str 0 l_sep) )
(cdr result)))))
(else
(cond
((string=? (substring str 0 l_sep) sep) (loop (substring str l_sep l_str) sep (cons "" result)))
(else
(loop (substring str 1 l_str) sep (cons (string-append (car result) (substring str 0 1) ) (cdr result))))))))))
(reverse (loop str sep '("")))))
在chez下测试成功。
例如:
> (split "How are you? I/m fine thank you" " ")
("How" "are" "you?" "I/m" "fine" "thank" "you")
> (split "12@345@@678@@@910" "@@")
("12@345" "678" "@910")。
然后,先这样把。
scheme的split实现的更多相关文章
- Partition:Partiton Scheme是否指定Next Used?
在SQL Server中,为Partition Scheme多次指定Next Used,不会出错,最后一次指定的FileGroup是Partition Scheme的Next Used,建议,在执行P ...
- Interrupt distribution scheme for a computer bus
A method of handling processor to processor interrupt requests in a multiprocessing computer bus env ...
- Partition5:Partiton Scheme是否指定Next Used?
在SQL Server中,为Partition Scheme多次指定Next Used,不会出错,最后一次指定的FileGroup是Partition Scheme的Next Used,建议,在执行P ...
- JQuery easyui里面的自动完成autocomplete插件
默认功能 当您在输入域中输入时,自动完成(Autocomplete)部件提供相应的建议.在本实例中,提供了编程语言的建议选项,您可以输入 "ja" 尝试一下,可以得到 Java 或 ...
- Android Scheme协议与应用全解析
URL Scheme 的作用 客户端应用可以向操作系统注册一个 URL Scheme,该 Scheme 用于从浏览器或其他应用中启动本应用. 通过指定的 URL 字段,可以让应用在被调起后直接打开某些 ...
- Registering an Application to a URI Scheme
https://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx Registering an Application to a URI Sc ...
- Lock-less and zero copy messaging scheme for telecommunication network applications
A computer-implemented system and method for a lock-less, zero data copy messaging mechanism in a mu ...
- Lock-less buffer management scheme for telecommunication network applications
A buffer management mechanism in a multi-core processor for use on a modem in a telecommunications n ...
- MIT Scheme Development on Ubuntu
sudo apt-get mit-scheme; run "scheme" then you enter the command line scheme repl; sudo ap ...
随机推荐
- jedisClient操作redis实现增删改查功能
这个集群环境下和单机环境下: package com.taotao.sso.dao.impl; import org.springframework.beans.factory.annotation. ...
- jsoncpp的安装与使用示例
安装: 生成静态库 生成静态库: 第一步:生成目标文件: g++ -g -Wall -c json_reader.cpp json_value.cpp json_writer.cpp -I. -I.. ...
- hive安装笔记
http://note.youdao.com/noteshare?id=bfbe59aef4ef7c3502975d3d575239e1
- 网络技术之TCP三次握手
在TCP/IP协议中,TCP协议提供可靠的连接服务,采用三次握手方式建立一个连接 第一次握手:c->s 建立连接时,客户端发送SYN包(syn=j){注:syn:Synchronize Sequ ...
- JIRA项目管理搭建
部署JIRA 7.2.2 for Linux 转自:http://www.yfshare.vip/2017/05/09/%E9%83%A8%E7%BD%B2JIRA-7-2-2-for-Linux/ ...
- SpringJMS解析--使用示例
Spring配置文件: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="h ...
- go语言学习之路(一)Hello World
为什么要使用 Go 语言?Go 语言的优势在哪里? 1.部署简单. 2.并发性好. 3.良好的语言设计. 4.执行性能好. Go环境搭建 Golang下载 国外镜像 https://www.gola ...
- php银行卡校验
前言银行金卡,维萨和万事达.银联品牌,如果是贷记卡或准贷记卡,一定为16位卡号.而借记卡可以16-19位不等.美国运通卡则不论金卡或是白金卡.普通卡,都是15位卡号.16-19 位卡号校验位采用 Lu ...
- Linux学习6-套接字
套接字 1.什么是套接字? 套接字(socket)是一种通信机制,凭借这种机制,客户/服务器系统的开发工作既可以在本地单机上进行,也可以跨网络进行. 2.套接字应用程序是如何通过套接字来维持一个连接的 ...
- 第8月第12天 python json.dumps danmu
1.json.dumps return JsonResponse({ 'status': WechatMessage.POST_METHOD_REQUIRED[1], 'status_code': W ...