scheme

Could anyone tell me something about Scheme Common-Lisp and FASL File

北战南征 提交于 2019-12-06 13:39:37
Can anyone tell me something about this file? As I know: Common-Lisp and Scheme are both dialects of lisp. Common-Lisp source file *.lisp can be compiled into binary file *.fasl which can be loaded faster than the source file. Q:Can the Scheme source code *.scm be compiled into some binary file that will be loaded faster than the source code? Thanks in advance, joe Yes, if the Scheme implementation you're using has that feature. FASL in Racket: http://docs.racket-lang.org/reference/fasl.html FASL in Chez Scheme: http://www.scheme.com/csug8/io.html#./io:h15 Alternatively, you could compile your

Arbitrary computation in Scheme macro

守給你的承諾、 提交于 2019-12-06 13:16:46
问题 Scheme macros, at least the syntax-case variety, are said to allow arbitrary computation on the code to be transformed. However (both in the general case and in the specific case I'm currently looking at) this requires the computation to be specified in terms of recursive functions. When I try various variants of this, I get e.g. main.scm:32:71: compile: unbound identifier in module (in the transformer environment, which does not include the run-time definition) in: expand-vars (The

Programatically filling in a letrec in Scheme. Macros or eval?

坚强是说给别人听的谎言 提交于 2019-12-06 11:11:59
I'm just playing with an NFA for string recognition. I have a macro that creates a function which consumes input and passes on the rest to some other functions. Because there might be loops in my NFA graph, I'm using letrec to put the whole thing together. Here is some code (been testing in PLT-Scheme): (define-syntax-rule (match chars next accepting) ; a function that consumes a list of chars from a list l. ; on success (if there's more to do) invokes each of next on the remainder of l. (lambda (l) (let loop ((c chars) (s l)) (cond ((empty? c) (cond ((and (empty? s) accepting) #t) (else

about the dot “.” in scheme

南楼画角 提交于 2019-12-06 10:55:57
I saw there are other questions about the dot "." I followed but it didn't work for my code.... it's a part of code, the implementation is not focused to this symbol. but output should be included this dot. when I give input of two lists '(1 2 3) '(4 5) my expected output => (1 . 4) (2 . 5) I managed to get (1 4) (2 5) just need to add "." in the middle. Part of mycode (cons (list (car lst1) (car lst2)) .... for the "." symbol , if I try **trial-1** (cons '(list (car lst1) (car lst2)) ...) then the output : ((list (car lst1) (car lst2)) **trail-2** (cons (list (car lst1) '. (car lst2)) ...)

Towers of Hanoi in Scheme (recursive)

浪子不回头ぞ 提交于 2019-12-06 10:46:46
I wrote the following code in scheme today, but the evaluation is wrong. Please don't tell me I suck at programming, I understand that this is a classic recursion problem, but I am having trouble with it: (define (towers-of-hanoi n source temp dest) (if (= n 1) (begin (display "Move the disk from ") (display source) (display " to " ) (display dest) (newline)) (begin (towers-of-hanoi (- n 1) source temp dest) (display "Move the disk from ") (display source) (display " to ") (display dest) (newline) (towers-of-hanoi(- n 1) temp source dest)))) I expected the code to work, and when I debug it I

Time Code in PLT-Scheme

空扰寡人 提交于 2019-12-06 10:33:10
I want to see how long a function takes to run. What's the easiest way to do this in PLT-Scheme? Ideally I'd want to be able to do something like this: > (define (loopy times) (if (zero? times) 0 (loopy (sub1 times)))) > (loopy 5000000) 0 ;(after about a second) > (timed (loopy 5000000)) Took: 0.93 seconds 0 > It doesn't matter if I'd have to use some other syntax like (timed loopy 5000000) or (timed '(loopy 5000000)) , or if it returns the time taken in a cons or something. The standard name for timing the execution of expressions in most Scheme implementations is "time". Here is an example

How do I define a sub environment in scheme?

被刻印的时光 ゝ 提交于 2019-12-06 09:52:16
问题 I am just hacking around with Scheme (mit-scheme) and I have just figured out how you change the environment, so that '+' becomes a symbol for the equivalent procedure of the '-' operator. Example (environment-define user-initial-environment '+ -) (eval (+ 3 2) user-initial-environment) => 1 I was just wondering if there were a simple way to deal with environments as variables so when I input an environment into eval, like so (eval <exp> user-initial-environment) I don't have to use 'user

Why is it legal in a function definition to make self-call but illegal for a value?

吃可爱长大的小学妹 提交于 2019-12-06 09:37:05
问题 Structure and Interpretation of Computer Programs (SICP) 3.5.2 introduces infinite streams: (define ones (cons-stream 1 ones)) This code doesn't work in DrRacket, with the error: ones: undefined; cannot reference an identifier before its definition Other code like this: (define (integers-starting-from n) (cons-stream n (integers-starting-from (+ n 1)))) (define integers (integers-starting-from 1)) produce error: Interactions disabled (fall in infinite loop?) So far as I read(SICP), the key

Scheme function [closed]

牧云@^-^@ 提交于 2019-12-06 09:34:54
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am trying to interpret what this scheme function does: (define (y s lis) (cond ((null? lis) '() ) ((equal? s (car lis)) lis) (else (y s (cdr lis))))) It runs but I am not exactly sure what it is doing or trying to do. Does it need a list to sort or something? I am using DrRacket to run it. I have never seen scheme before and any help would be greatly appreciated. It's a search function, that given a value and

Android Saripaar 注解详解

大城市里の小女人 提交于 2019-12-06 08:49:38
写这篇文章的原因 在移动端一般很少使用复杂的表单,一般针对于属性的更改都会打开一个新的页面进行更改。虽然不多,但是也会有。如果一个页面要输入的内容包括姓名、地址、邮箱、手机号等,对各个属性的验证会非常麻烦,并且非常的不优雅。 于是, saripaar 就出现了,一种基于规则的 Android UI 输入验证库,通过注解即可标注验证规则。 使用过程中发现只有四个字: 简单好用 。但是 官方 对注解的使用并没有一份完整的文档,故参考源码整理了现有的所有注解(基于版本 2.0.3 )。 如何使用 导入依赖 第一步当然是导入依赖啦,可通过 implementation 'com.mobsandgeeks:android-saripaar:(latest version)' 导入 saripaar ,将 (latest version) 替换为最新版本即可。 使用注解 对需要进行验证的 可输入View 加上注解来标注验证规则,例 @Length(min = 6, max = 9) private AppCompatEditText et1; 该注解表示 et1 中的输入内容长度只能在6到9的闭区间。 实例化 Validator mValidator = new Validator(this); mValidator.setValidationListener(this); Validator