Scheme - how do I modify an individual element in a list?
If I have a list of 0's, how would I modify, for example, the 16th 0 in the list? ...
If I have a list of 0's, how would I modify, for example, the 16th 0 in the list? ...
Refering to Variable Scoping. I'm trying to figure out what are the differences between those 2. For example, Anonymous functions in a scheme function has access to the variables local to that function. Does python have this? Thanks! ...
I'm porting some code from lisp, but I got stuck at this part (apparently that's for mit-scheme) (define (end-of-sentence? word) (and (or (char-exist-last? word '#\.) (char-exist-last? word '#\!) (char-exist-last? word '#\?)) (not (initial? word)) (or (eq? (peek-char) '#\Space) ;;peek- so test for l...
How do I do equivalent of python's str.split in DrScheme? SRFI-13 doesn't seem to have it provided. ...
Suppose I have a simple symbol: > '+ + Is there any way I can apply that symbol as a procedure: > ((do-something-with '+) 1 2) 3 So that '+ is evaluated to the procedure +? ...
i'm learning sicp now and do the ex2.23 i have wrirten the following code: (define (for-each proc items) (if (null? items) #t ((proc (car items)) (for-each proc (cdr items))))) but when running, cause error: procedure application: expected procedure, given: #; arguments were: () i think i know the reason: I c...
I develop in Lisp and in Scheme, but I was reading about Clojure and then I want to know, in which cases is better to use it than using Lisp or Scheme? Thanks ...
Lots of Prolog-in-Scheme implementations are out there. E.g. Kanren, Schelog. Apparently in "Paradigms of AI Programming" Norvig implements Prolog-to-Lisp compiler in Lisp in order to use Definite Clause Grammars. But is there a simpler cleaner way? Maybe some clever use of amb to avoid implementing a full "Prolog"? What is the easiest...
I am learning hygiene and I tried to make a simple for loop in Scheme. I want to support three kinds of constructs as shown in example below (for i = 1 : (< i 4) : (++ i) (printf "Multiplication Table for ~s\n" i) (for j = 1 to 5 (printf "~s * ~s = ~s\n" i j (* i j)))) I want to also support for loops with filters like this:...
I am learning continuations but I can't wrap my head around this code. Why does it go into infinite loop? (let ((cont #f)) (call/cc (lambda (k) (set! cont k))) (cont #f)) ...
Is it possible to add another function procC in here so that the sequence of evaluation is procA->procB->procC->procA ... ? (define (procA another-fun) (let loop ((n 5)) (display "In Proc A \n") (set! another-fun (call/cc another-fun)) (when (> n 0) (loop (- n 1))))) (define (procB another-fun) (let loop ((n 5)) ...
Before someone asks, this is not a homework, I am a Spanish major, but I would like to understand some programming... (define (x lis) (cond ((null?? lis) 0) ((not (list? (car lis))) (cond ((eq? (car lis) nil) (x (cdr lis))) (else (+1 (x (cdr lis)))))) (else (+ (x (car lis)) (x (cdr ...
Hi, I'm new to programming, working my way through SICP, and loving it. Though I'm a bit confused about scheme's define syntax, mainly, what's the difference between: (define foo bar) and: (define (foo) bar) Is the first one just assigns bar to foo and execute it? While the second assigns and waits for the call? if so how would yo...
Hello, I am trying to implement a breadth first (level) tree traversal. I'm very close, but I can't figure out how I'm getting duplicates. Any help is much appreciated. Thanks in advance. JR (define (atom? x) (not (pair? x))) ;;Functions to manipulate a binary tree (define (leaf? node) (atom? node)) (define (left node) (cadr node)...
I'm looking at ways to embed Lisp or Scheme in a C program, but I want to do so without growing the program size considerably. It doesn't need to be fast, or support lots of features. (Though macros would be nice.) This is not a math-intensive application. Please list the smallest embeddable interpreter for a Lisp-like language you k...
I'd prefer examples to be in a Lisp variant (bonus points for Clojure or Scheme) since that's what I'm most familiar with, but any feedback regarding DBC in functional lanugages would of course be valuable to the greater community. Here's an obvious way: (defn foo [action options] (when-not (#{"go-forward" "go-backward" "turn-right...
In Python I can do "x in list" to see if the list contains x. Is there any equivalent built-in in Scheme to do this? ...
I'm considering learning a Lisp dialect (probably Scheme, since I am constantly hearing how good of a learning language it is) in order to improve my general programming skill. Apart from the fact that learning any new language helps you to be a better programmer in general, how can learning Lisp make me a better C# programmer? ...
I'm trying to make sense of the example code here (below Examples). I don't understand that parametrize construct. The docs for it are here, but they don't help. What does it do? ...
Hi, I'm trying to use scheme to write a function f that takes a number n and a function g and returns a list of lists of length n, but according with booleans according to the pattern indicated by g. For example, the function f should take n say 3 and the function g which makes every 3rd item on the list a true. It should return this: ...