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 ...
随机推荐
- 基于CMS的组件复用实践
目前前端项目大多基于Vue.React.Angular等框架来实现,这一类框架都有一个明显的特点:基于模块化以及组件化思维.所以,开发者在使用上述框架时,实际上是在写一个一个的组件,并且组件与组件之间 ...
- Maven的国内镜像(解决jar下载过慢)
Maven简介 maven作为一个项目管理工具确实非常好用,结果在使用时候,你会发现下载jar速度不如自己在网上下载.之前oschina的中央仓库可用,现在oschina的maven服务器关了,只能拿 ...
- html5 canvas 垂直渐变描边
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 关于MYSQL group by 分组按时间取最大值的实现方法
类如 有一个帖子的回复表,posts( id , tid , subject , message , dateline ) , id 为 自动增长字段, tid为该回复的主题帖子的id(外键关联), ...
- 克隆虚拟机重启之后eth0不见的解决方案
今天用虚拟机克隆多一个虚拟机的时候,发现克隆之后的新虚拟机的网卡eth0在配置之后完全是用不了的,下面说一下我的解决办法,亲测可用. 1.用ipconfig命令查看ip信息的时候会发现虚拟机没有找到e ...
- Web安全测试-WebScarab
[功能] WebScarab是一个用来分析使用HTTP和HTTPS协议的应用程序框架.其原理很简单,WebScarab可以记录它检测到的会话内容(请求和应答),并允许使用者可以通过多种形式来查看记录. ...
- Servlet笔记9--Cookie
Cookie: 使用Cookie机制实现十天内免登陆: Servlet程序: package com.bjpowernode.javaweb.servlet; import java.io.IOExc ...
- rtop:一个通过 SSH 监控远程主机的交互式工具【转】
编译自: http://www.tecmint.com/rtop-monitor-remote-linux-server-over-ssh/ rtop[1] 是一个基于 SSH 的直接的交互式远程系统 ...
- pip 18.1: pipenv graph results in ImportError: cannot import name 'get_installed_distributions'
I'm currently using python3 -m pip install pip==10.0.1python3 -m pip install pipenv==2018.5.18 Once ...
- 数据库索引和SQL语句使用经验
1.如果检索数据量超过30%的表中记录数,使用索引将没有显著的效率提高 2.在特定情况下,使用索引也许会比全表扫描慢,但这是同一个数量级上的差距:而通常情况下,使用索引比全表扫描要快几倍乃至几千倍! ...