scheme

Implementation of Curried Functions in Scheme

℡╲_俬逩灬. 提交于 2019-12-10 10:29:21
问题 What happens when I do the following? (define ((func x) y) (if (zero? y) ((func x) 1) 12)) I understand that I can do this: (define curried (func 5)) And now I can use curried. What I'm curious about is in the definition of the function. Does the line ((func x) 1) create a new lambda with x as the argument, and then invoke it on 1? Or is it smarter than that and it just re-uses the existing one. (For example, if I do (curried 0) , the ((func x) 1) line would be equivalent to (curried 1) -

DrRacket EOPL Scheme output

社会主义新天地 提交于 2019-12-10 10:26:44
问题 I am working through the EOPL Scheme exercises using DrRacket in Windows 7. When I switch from #lang racket to #lang eopl, the output from the definitions pane no longer shows up in the interaction pane. To be clear, as trivial example, running #lang racket 4 produces 4 > as you would expect. But running #lang eopl 4 produces only > Is there anything I can do to change this behavior or is there another pane I should be looking at for output? I can, of course, evaluate expressions in the

小白学 Python 爬虫(14):urllib 基础使用(四)

南笙酒味 提交于 2019-12-10 08:49:00
人生苦短,我用 Python 前文传送门: 小白学 Python 爬虫(1):开篇 小白学 Python 爬虫(2):前置准备(一)基本类库的安装 小白学 Python 爬虫(3):前置准备(二)Linux基础入门 小白学 Python 爬虫(4):前置准备(三)Docker基础入门 小白学 Python 爬虫(5):前置准备(四)数据库基础 小白学 Python 爬虫(6):前置准备(五)爬虫框架的安装 小白学 Python 爬虫(7):HTTP 基础 小白学 Python 爬虫(8):网页基础 小白学 Python 爬虫(9):爬虫基础 小白学 Python 爬虫(10):Session 和 Cookies 小白学 Python 爬虫(11):urllib 基础使用(一) 小白学 Python 爬虫(12):urllib 基础使用(二) 小白学 Python 爬虫(13):urllib 基础使用(三) Parse 模块 官方文档: https://docs.python.org/zh-cn/3.7/library/urllib.parse.html 前面我们介绍了 urllib 的 Request 模块和 Error 模块,本篇我们接着介绍 Parse 模块。 先看一下官方文档的解释吧: This module defines a standard interface to

How does `if` statement work in Scheme?

好久不见. 提交于 2019-12-10 08:26:11
问题 This is the link that I'm current teaching myself Scheme, http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-1.html According to the author, Then I tried a minimal example (define (check-p x) (if (>= x 0) (display 1))) , and DrScheme gave me errors: if: bad syntax (must have an "else" expression) in: (if (>= x 0) (display 1)) If I put an extra statement within the if statement, then it works. But I don't get it, why do we need an extra statement there? The code statement above made

Analog of Python's range in Scheme

こ雲淡風輕ζ 提交于 2019-12-10 02:56:33
问题 How to create a list of consecutive numbers in Scheme? In Python to create a list of integers from 1 to 10 would be range(1,11) . Is there an equivalent for Scheme? mzscheme --version gives Welcome to Racket v5.2.1. Edit: Per https://stackoverflow.com/a/7144310/596361 to implement range functionality, this code is needed: #lang racket (require srfi/1) (iota 5 1) 回答1: Look for iota (as defined in SRFI-1). Example: (iota 10 1) gives 10 consecutive integers starting from 1 (instead of the

Does learning one Lisp help in learning the other?

大城市里の小女人 提交于 2019-12-10 02:33:40
问题 Is there any synergy between learning different Lisp languages? I'm currently learning Emacs Lisp, as it is immediately useful in my daily Emacs usage, however i'm fascinated with all Lisps, so maybe someday i will learn and use others. Will learning Emacs Lisp help me, when i start digging in Common Lisp, Scheme or Clojure? In other words, will it be for me like learning a completely new language, or some notions and paradigms are common? I'm also interested in comparison of unique

Deeplink实践原理分析

廉价感情. 提交于 2019-12-09 19:10:24
目录介绍 01.先看一个场景 02.什么是DeepLink 03.什么是Deferred DeepLink 04.什么是AppLink 05.DeepLink和AppLink核心技术 06.DeepLink实践方案 07.AppLink实践方案 08.部分问题思考总结 09.DeepLink原理分析 10.AppLink原理分析 01.先看一个场景 假设一个场景: 小明告诉小杨,一鹿有车APP上有一个很有创意的抽奖活动,小新想要参与这个活动 如果小杨已经安装了APP,他需要找到且打开APP,然后找到相应的活动,共计2步; 如果小杨没有安装APP,他需要在应用市场搜索一鹿有车APP、下载、打开APP且找到相应的活动,共计4步; 关于那些途径实现 通过短信息,比如收到脉脉好友信息,通过短信息打开app跳转制定页面。 通过短信息,比如收到天猫推荐消息,通过短信息打开浏览器,然后通过浏览器跳转指定页面。 通过分享到微信中h5页面,在微信中打开app(这个需要到微信开放平台做配置,其实是微信——>应用宝——>app指定页面)。 提出的需求: 在浏览器或者短信中唤起APP,如果安装了就唤起,否则引导下载。对于Android而言,这里主要牵扯的技术就是deeplink,也可以简单看成scheme,Android一直是支持scheme的,本文只简单分析下link的原理,包括deeplink

Functional Programming - Implementing Scan (Prefix Sum) using Fold

谁都会走 提交于 2019-12-09 18:44:03
问题 I've been teaching myself functional programming, and I'm currently writing different higher order functions using folds. I'm stuck implementing scan (also known as prefix sum). My map implementation using fold looks like: (define (map op sequence) (fold-right (lambda (x l) (cons (op x) l)) nil sequence)) And my shot at scan looks like: (define (scan sequence) (fold-left (lambda (x y) (append x (list (+ y (car (reverse x)))))) (list 0) sequence)) My observation being that the "x" is the

CLI shell script code generation from compiled executable? [closed]

一笑奈何 提交于 2019-12-09 15:59:01
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . Question, topic of discussion I am very interested in generation of command line shell scripting source code from code written in a

Scheme, SICP, R5RS, why is delay not a special form?

三世轮回 提交于 2019-12-09 10:29:03
问题 This is concerning chapter 3.5 from SICP, in which streams are being discussed. The idea is that: (cons-stream 1 (display 'hey)) Should not evaluate the second part of the cons-stream, so it should not print “hey”. This does happen, I get the following output: hey(1 . #< promise >) So my conclusion is that delay is not implemented as a special form? Or am I doing something wrong? I use the following implementation: (define (cons-stream a b) (cons a (delay b))) With delay being the default