racket

How to run scheme with Emacs?

泪湿孤枕 提交于 2019-12-03 04:17:01
问题 I followed this tutorial and successfully installed Emacs, STk, Quack. The question is how can I load my program like I do in Racket? In Racket I can edit my code in the upper window, type some codes, save and run. Then the lower window will automatically loaded the code I just wrote. Then I can play with it. I've tried M-x run-scheme. It only brings me into type mit-scheme. Then it says No such file or directory exists. Then I tried F5 (The author from the site wrote a .emacs file enables me

Racket URL dispatch

…衆ロ難τιáo~ 提交于 2019-12-03 03:25:15
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-post) (("archive" (integer-arg) (integer-arg)) review-archive) (else list-posts))) (define (list-posts

Setting Racket Geiser Emacs Path

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm trying to get Geiser's REPL to work in Emacs, but it doesn't seem to be able to find Racket. racket is on my path, but anytime I type run - geiser followed by racket it complains: Unable to start REPL: Searching for program: no such file or directory, racket I read in the Geiser docs that I may have to manually tell Geiser where to find racket , but I can't tell where to configure this property of Geiser. Thanks for your help. 回答1: Ok, so I added: ( setq geiser - racket - binary "/home/user/racket/bin/racket" ) to my .emacs

set-car!, set-cdr! unbound in racket?

匿名 (未验证) 提交于 2019-12-03 01:46:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am just trying to do very simple code with set-car! and set-cdr! in racket , but I got the error: expand: unbound identifier in module in: set-car! and expand: unbound identifier in module in: set-cdr! Aren't they defined in racket ? Could anyone help? 回答1: You need to import mutable-pairs-6 , like this: (require rnrs/mutable-pairs-6) Those procedures were moved to a different module and renamed to mcons , mcar , mcdr , set-mcar! , set-mcdr! , mlist to emphasize that they operate on mutable data, unlike their immutable counterparts. 回答2:

What is scheme's equivalent of tuple unpacking?

放肆的年华 提交于 2019-12-03 01:45:30
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. 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 multiple values, you'd use define-values : (define (t) (values 1 2)) (define-values (a b) (t)) or let

Differences between #lang scheme and #lang racket

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm guessing that #lang racket is a dialect of scheme with much more out of the box structures and common functions and perhaps would be more pedagogic. What are the perks a #lang racket against #lang scheme? Is it best (or even possible) to use #lang scheme in racket to follow all the content of 'Structure and Interpretation of Computer Programs' or even 'How to Design Programs'. HtDP is #lang racket specific? Whatever code written in #lang scheme, as long as libraries are not being included, can be used in chicken scheme or any main

What are the actual differences between Scheme and Common Lisp? (Or any other two dialects of Lisp)

。_饼干妹妹 提交于 2019-12-03 00:41:48
问题 Note: I am not asking which to learn, which is better, or anything like that. I picked up the free version of SICP because I felt it would be nice to read (I've heard good stuff about it, and I'm interested in that sort of side of programming). I know Scheme is a dialect of Lisp and I wondered: what is the actual difference is between Scheme and, say, Common Lisp? There seems to be a lot about 'CL has a larger stdlib...Scheme is not good for real-world programming..' but no actual thing

Turning structural recursion into accumulative recursion in Racket

不问归期 提交于 2019-12-02 23:33:39
问题 I have some code to find the maximum height and replace it with the associated name. There are separate lists for height and names, each the same length and non-empty. I can solve this using structural recursion but have to change it into accumulative, and I am unsure how to do that. All the examples I have seen are confusing me. Is anybody able to turn the code into one using accumulative recursion? (define (tallest names heights) (cond [(empty? names) heights] [(> (first heights) (first

How to find “not a procedure” error

最后都变了- 提交于 2019-12-02 23:23:03
问题 (define (comp f g) (lambda (x)(f (g x)))) (define (complement f) (cond ((equal? (comp f (lambda (g) g)) #t) #f) ((equal? (comp f (lambda (g) g)) #f) #t))) ((complement odd?)2) It keeps saying that ((complement odd?)2) is not a procedure. I'm not sure how to fix it. 回答1: When you run this code you'll see that ((complement odd?) 2) is red in the definitions and you get the following error: application: not a procedure; expected a procedure that can be applied to arguments given: #<void> So that

Scheme changing tree values

六月ゝ 毕业季﹏ 提交于 2019-12-02 20:23:07
问题 I need to implement a procedure called inverse-tree that receives a tree whose nodes data values are numbers and booleans and returns the equivalent tree whose nodes satisfy the following: If the equivalent node of the original tree is a number, then the resulting tree’s node is −1· that node value If the equivalent node of the original tree is a boolean, then the resulting tree’s node is the logical not of that node value Examples: > (inverse-tree ’()) ’() > (inverse-tree ’(5)) ’(-5) >