scheme

Difference between load and include in Scheme R7RS

心已入冬 提交于 2020-07-08 21:07:11
问题 In Scheme R7RS there is both a load and include form. Include is described as: Semantics: Both include and include-ci take one or more filenames expressed as string literals, apply an implementation-specific algorithm to find corresponding files, read the contents of the files in the specified order as if by repeated applications of read, and effectively re- place the include or include-ci expression with a begin expression containing what was read from the files. The difference between the

Can someone explain the concept of 'hygiene' to me (I'm a scheme programmer)?

若如初见. 提交于 2020-07-04 20:15:33
问题 So... I'm new to scheme r6rs, and am learning macros. Can somebody explain to me what is meant by 'hygiene'? Thanks in advance. 回答1: Hygiene is often used in the context of macros. A hygienic macro doesn't use variable names that can risk interfering with the code under expansion. Here is an example. Let's say we want to define the or special form with a macro. Intuitively, (or a b c ... d) would expand to something like (let ((tmp a)) (if tmp a (or b c ... d))) . (I am omitting the empty (or

Little Schemer atom vs (quote atom)

左心房为你撑大大i 提交于 2020-06-27 16:54:06
问题 I've just started reading The Little Schemer . It starts off with several questions asking if a given expression is an atom. It's pretty straightforward but, funny enough, the very first question is throwing me off a bit. It asks: Is it true that this is an atom? atom 1 1 (quote atom) or ’atom What's throwing me off is the footnote reference. They're asking if atom is an atom, but then somehow they're saying that atom is really (quote atom) or ’atom ? I just don't get it. 回答1: What’s going on

How to debug script-fu scripts for gimp in scheme?

∥☆過路亽.° 提交于 2020-06-15 23:51:11
问题 I try to make some script for gimp, using script-fu, scheme. Naturally, as a beginner, there are lots of errors and misunderstandings. Now I'm looking for a way to debug those scripts. I found (gimp-message), but the result does not show up. I'm not aware if there is a possibility to print debug messages to anywhere I could check them. Generating new images filled with text would probably work ;-) but looks a bit like an overkill. What ways to debug a script in gimp are there? 回答1: The output

How to debug script-fu scripts for gimp in scheme?

纵饮孤独 提交于 2020-06-15 23:50:51
问题 I try to make some script for gimp, using script-fu, scheme. Naturally, as a beginner, there are lots of errors and misunderstandings. Now I'm looking for a way to debug those scripts. I found (gimp-message), but the result does not show up. I'm not aware if there is a possibility to print debug messages to anywhere I could check them. Generating new images filled with text would probably work ;-) but looks a bit like an overkill. What ways to debug a script in gimp are there? 回答1: The output

Update functions in Hash Table in Racket

懵懂的女人 提交于 2020-06-09 04:19:23
问题 I am a beginner in Racket and I am trying to updare a hash table using hash-update! where the value is a mutable set. Below are the code lines: (hash-update! hash key (curryr set-add! new_val) (mutable-set 1)) However I receive an error expected: set? given: #<void> argument position: 1st other arguments...: x: 2 where I tried 2 as the new_val Any suggestions ? 回答1: This is because the updater is supposed to be a function that takes a value as input and produces a new value output. Since the

Custom eqv?/equal? function in scheme

爷,独闯天下 提交于 2020-06-01 06:29:26
问题 How would I go about writing my own eqv? or equal? in scheme? Would I just do a cond and look for symbol?, number?, etc and return the appropriate #t or #f? 回答1: As per R5RS, the minimum specifications for an implementation of eqv? (when passed two arguments obj1 and obj2 ) to evaluate to #t are: obj1 and obj2 are both #t or both #f . (how two boolean literals evaluate to the same value is implementation dependent). obj1 and obj2 are both symbols and (string=? (symbol->string obj1) (symbol-

clojure: no cons cells

不问归期 提交于 2020-05-28 12:44:27
问题 i heard that clojure does not have cons cells as of most lisp languages. does that mean a clojure list does not end with an empty list? could anyone explain what that exactly means? 回答1: Lisp provides a primitive cons data structure and a notation for it. See John McCarthy, Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I, 1960, Chapter 3, Recursive Functions of Symbolic Expressions. That chapter introduces: Symbolic expressions made of atoms and pairs of

clojure: no cons cells

a 夏天 提交于 2020-05-28 12:44:03
问题 i heard that clojure does not have cons cells as of most lisp languages. does that mean a clojure list does not end with an empty list? could anyone explain what that exactly means? 回答1: Lisp provides a primitive cons data structure and a notation for it. See John McCarthy, Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I, 1960, Chapter 3, Recursive Functions of Symbolic Expressions. That chapter introduces: Symbolic expressions made of atoms and pairs of

(Chez) Scheme macro for hiding lambdas

廉价感情. 提交于 2020-05-13 14:35:56
问题 I would like to write a macro to create shorthand syntax for hiding more verbose lambda expressions, but I'm struggling to understand how to write macros (which I realize is an argument against using them). Given this example: (define alist-example '((x 1 2 3) (y 4 5 6) (z 7 8 9))) (define ($ alist name) (cdr (assoc name alist))) ((lambda (a) (map (lambda (x y z) (+ x y z)) ($ a 'x) ($ a 'y) ($ a 'z))) alist-example) ((lambda (a) (map (lambda (y) (/ y (apply max ($ a 'y)))) ($ a 'y))) alist