I have a problem in my function where I'm only able to match 1 element in a list, as soon as it hits the first match it results #t. but I want to be able to match all the values in the list. say x1(1111 . 9999), they both should match the list x2(111
I'm new to racket and trying to write a function that checks if a list is in strictly ascending order. '( 1 2 3) would return true '(1 1 2) would return false (repeats) '(3 2 4) would return false My code so far is: Image of code (define (ascending?
I've been struggling with this question for a lot now. Could someone please explain the logic behind the program by using the simplest way possible possibly recursion? Thank you.Have 2 variables (say x and y) Move through the list of numbers Keep lar
I am new to Racket. I need to sum all the natural numbers less than 1000 (or any nth value) and the numbers will be divisible by 3 or 5. I have a code which can do that but using iteration. But I have to do same thing by recursion. The code is as fol
I am studying NLP with Racket and Dr. Racket. I am working with this code: #lang racket (define english-1 '((Initial (1)) (Final (9)) (From 1 to 3 by NP) (From 1 to 2 by DET) (From 2 to 3 by N) (From 3 to 4 by BV) (From 4 to 5 by ADV) (From 4 to 5 by
If 'apply' applies the given function to all elements of list, why following does not work: > (apply println (list "a" "b" "c")) . . println: contract violation expected: output-port? given: "b" argument position
(define unique (lambda (L) (cond ((null? L) L) ((null? (cdr L)) L) ((eqv? (car L) (car (cdr L))) (unique (cdr L))) (else (cons (car L) (unique (cdr L)))))) This above code(#racket language) finds the unique elements from the list. I want to translate
Is there an easy way to display whole rational numbers for example: (average '(1 2 3 4)) ;returns 2 1/2 I would like it to return 5/2. Thank you.This is DrRacket-specific behavior. It customizes the Racket print handler to print out certain values in
I just installed racket-mode in my emacs 24.3, when I run the REPL via racket-repl command, the REPL starts correctly, but some of the racket procedures/functions aren't recognized. i.e > (class object%) ; class: undefined; ; cannot reference undefi
I want to write a function which for n arguments will create n lists and each contains n-th element for every argument, for example: (aux '(1 2) '(3 4)) = `((1 3) (2 4)) I wrote such a function: (define (aux . args) (if (null? args) '() (cons (map ca
I was wondering how one could implement a kind of "Remote Method Invocation" (in a very simplistic form). I'm writing a program in an object oriented way. I have objects living on the raspberry pi and objects living on my computer. So sometimes
I am trying to make a helper function that will take input of switched syntax. Helper function needs to be able to do: > (num sqr) ; where num=6, and sqr is the math function square. 36 Originally, the built-in syntax would be: >(sqr num) ; where nu
How do I convert all chars of a port to a string or a list so that I can operate on it as either a list of chars or a string? I was wondering if something similar to (define (port->list port) (list port)) is possible.Racket provides a built-in port->
ts-guide said: In addition to the : form, almost all binding forms from racket have counterparts which allow the specification of types. But it does not say when to use which one. And ts-reference said form: is legacy, for backwards compatibility. Bu
i searched the internet for hours, but didn't find a satisfying answer to what's the difference between the first and second version of HTDP (How to design programs)? Why should I start with the second version, instead of the first one? As the second
By unsided fold, I mean a hypothetic primitive fold operation for associative operators that, does not guarantee any ordering. That is, (fold + 0 [a b c d]) could be (+ (+ a b) (+ c d)) or (+ (+ (+ a b) c) d). Given that this operation is fusionable,
I want to define a constant foo using an auxiliary function, say, bar. And I want to hide bar inside the definition of foo, so I come with this code: (define foo (define (bar n) (+ n n)) (bar 1)) However, this definition causes syntax errors in many
I am newbie to Scheme programming and trying to define a var in if condition. For example, I have: (if (< x y) (define x y) ) ;(GOAL: if x < y, than x=y..) But I got the error: let: bad syntax (not an identifier and expression for a binding) in:...
Can someone please explain these functions for me in racket. I`m totally lost. Please help me with some examples. Thanks! I just cannot figure these functions out for the life of me.First, the If: (if (positive? 1) 1 -1) Racket first evaluates if 1 i
#lang eopl (define (expo base n ) (cond( (or (= base 1) (= n 0) ) 1) (else ( (* base (expo(base (- n 1))) ) ) ))) -> (enter! "expo.rkt") "expo.rkt"> (expo (2 1) ) ; application: not a procedure; ; expected a procedure that can be
I use DrRacket. I have problem with this code: (define (qweqwe n) ( (cond [(< n 10) #t] [(>= (lastnum n) (pochtilastnum n)) (qweqwe (quotient n 10))] [else #f] ) ) ) (define ( RTY file1 file2 ) (define out (open-output-file file2 #:mode 'text #:exis
Can anyone tell me what I need to do here? (define (count-values abst v) (cond [(empty? abst) 0] [else (+ (cond [(equal? v (bae-fn abst)) 1] (else 0)) (count-values .... v) (count-values .... v ))])) I basically need a function that counts the amount
So I know that in Scheme define is for dynamic scoping and let for static scoping, yet the following thing confuses me: If I have (let ((x 0)) (define f (lambda () x)) (display (f)) (let ((x 1)) (display (f)) ) ) It will display 00. So far so good. H
i've been pulling my hair trying to figure this out. i'm suppose to design a function takes in a hstudent, i get another student with the same contents and with his age converted into dog years. any ideas on how to start? This exact question is going
Functions in scheme/racket. Working on a few functions using a binary search tree. I have already defined helper functions to be: ;; returns value of node (define (value node) (if (null? node) '() (car node))) ;; returns left subtree of node (define
I hacked together several code snippets from various sources and created a crude implementation of a Wolfram Blog article at http://bit.ly/HWdUqK - for those that are mathematically inclined, it is very interesting! Not surprisingly, given that I'm s
I am currently playing around with LISP. Everything is fine, but I can't understand the following issue. I have the this append-operation: (define (append l1 l2) (if (eq? l1 null) l2 (cons (first l1) (myappend (rest l1) l2)))) I use it like this: (my
I have downloaded Arc 3.1 and Racket in my Windows 7 machine, and solved many errors while proceeding. But still when I run mzscheme -f as.scm it never returns to the prompt (as if there was an infinite loop). When I use mzscheme -m -f as.scm, it sho
I'm trying to create a list by adding a number to an existing list. The problem is that the existing list is not necessarily actually a list. It could be either an empty list ((list )), just a number, or an actual list. Basically, I need something li
the format can turn any type into a string, e.g (define lam-form (list `lambda (list `x ) (list `when (list `> `x 0) (list `* 100 `x )))) (format "~s" lam-form) result will be: "(lambda (x) (when (> x 0) (* 100 x)))" Then my ques