scheme

removing last element of a list(scheme)

元气小坏坏 提交于 2019-12-03 16:37:08
问题 So I have to remove the last element of a list in scheme. For example, let's say I have a list (1 2 3 4) . I need to return: (1 2 3) My idea: reverse(list) car(list) reverse(list) Is there a reverse function in scheme(racket)? 回答1: You wrote: "reverse, car, reverse". I believe you meant to write "reverse, cdr, reverse". There's nothing wrong with this solution; it's linear in the size of the list, just like any solution to this that uses the standard lists. As code: ;; all-but-last: return

Scheme add element to the end of list [closed]

独自空忆成欢 提交于 2019-12-03 16:01:41
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center . Closed 7 years ago . How can you add an element to the end of a list (before the empty) when only cons, first, rest, empty? and cond recursions can be used Chris Jester-Young Think about how you would implement append (or, more generally, think about how you would implement a

HTML 统一资源定位器(Uniform Resource Locators)

妖精的绣舞 提交于 2019-12-03 15:49:18
URL 是一个网页地址。 URL可以由字母组成,如"runoob.com",或互联网协议(IP)地址: 192.68.20.50。大多数人进入网站使用网站域名来访问,因为 名字比数字更容易记住。 URL - 统一资源定位器 Web浏览器通过URL从Web服务器请求页面。 当您点击 HTML 页面中的某个链接时,对应的 <a> 标签指向万维网上的一个地址。 一个统一资源定位器(URL) 用于定位万维网上的文档。 一个网页地址实例: http://www.runoob.com/html/html-tutorial.html 语法规则: scheme :// host.domain : port / path / filename 说明: scheme - 定义因特网服务的类型。最常见的类型是 http host - 定义域主机(http 的默认主机是 www) domain - 定义因特网域名,比如 runoob.com :port - 定义主机上的端口号(http 的默认端口号是 80) path - 定义服务器上的路径(如果省略,则文档必须位于网站的根目录中)。 filename - 定义文档/资源的名称 常见的 URL Scheme 以下是一些URL scheme: Scheme 访问 用于... http 超文本传输协议 以 http:// 开头的普通网页。不加密。 https

动作识别新论文:A Novel Scheme for Training Two-Stream CNNs for Action Recognition

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 13:43:53
A Novel Scheme for Training Two-Stream CNNs for Action Recognition 创新点 1.使用cur算子来代表运动信息 2.提升了速度运算 3.依然是使用双端网络模型 4.对训练的的时候,收敛条件的判断,可以提速: pdf地址: https://link.springer.com/content/pdf/10.1007%2F978-3-030-33904-3.pdf 代码地址: 来源: https://www.cnblogs.com/captain-dl/p/11797654.html

Racket URL dispatch

喜欢而已 提交于 2019-12-03 13:19:41
问题 I'm trying to hook up URL dispatch with Racket (formerly PLT Scheme). I've taken a look at the tutorial and the server documentation. I can't figure out how to route requests to the same servlets. Specific example: #lang scheme (require web-server/servlet) (require web-server/dispatch) (provide/contract (start (request? . -> . response/c))) (define (start request) (blog-dispatch request)) (define-values (blog-dispatch blog-url) (dispatch-rules (("") list-posts) (("posts" (string-arg)) review

Mauritus national flag problem

浪尽此生 提交于 2019-12-03 12:59:40
I've made a solution for the Dutch national flag problem already. But this time, I want to try something more difficult: the Mauritus national flag problem - 4 colours, instead of 3. Any suggestions for an effective algorithm? Basically, The Mauritius National Flag Problem focuses on how you would be able to sort the given list of pairs based on the order of colors in the Mauritius National Flag (Red, Blue, Yellow, Green). And the numbers must be sorted in ascending order too. Scheme Programming Sample Input: ( (R . 3) (G . 6) (Y . 1) (B . 2) (Y . 7) (G . 3) (R . 1) (B . 8) ) Output: ( (R . 1)

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

我与影子孤独终老i 提交于 2019-12-03 12:55:35
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 R5RS implementation. Is this a fault in the implementation, or am I not doing or understanding it right?

Implementing Iota in Haskell

我只是一个虾纸丫 提交于 2019-12-03 12:49:27
Iota is a ridiculously small "programming language" using only one combinator. I'm interested in understanding how it works, but it would be helpful to see the implementation in a language I'm familiar with. I found an implementation of the Iota programming language written in Scheme. I've been having a little trouble translating it to Haskell though. It's rather simple, but I'm relatively new to both Haskell and Scheme. How would you write an equivalent Iota implementation in Haskell? (let iota () (if (eq? #\* (read-char)) ((iota)(iota)) (lambda (c) ((c (lambda (x) (lambda (y) (lambda (z) ((x

Which environment, IDE or interpreter to put in practice Scheme?

戏子无情 提交于 2019-12-03 12:10:12
问题 I've been making my way through The Little Schemer and I was wondering what environment, IDE or interpreter would be best to use in order to test any of the Scheme code I jot down for myself. 回答1: Racket (formerly Dr Scheme) has a nice editor, several different Scheme dialects, an attempt at visual debugging, lots of libraries, and can run on most platforms. It even has some modes specifically geared around learning the language. 回答2: I would highly recommend both Chicken and Gauche for

What is scheme's equivalent of tuple unpacking?

假装没事ソ 提交于 2019-12-03 11:21:45
问题 In Python, I can do something like this: t = (1, 2) a, b = t ...and a will be 1 and b will be 2. Suppose I have a list '(1 2) in Scheme. Is there any way to do something similar with let ? If it makes a difference, I'm using Racket. 回答1: In racket you can use match, (define t (list 1 2)) (match [(list a b) (+ a b)]) and related things like match-define: (match-define (list a b) (list 1 2)) and match-let (match-let ([(list a b) t]) (+ a b)) That works for lists, vectors, structs, etc etc. For