Check the ascending order of a list in Racket

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?

Need help finding the second largest number in a list. Racket

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

Racket Conditional Sum Sum by Recursion

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

NLP with racket

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

Application example other than + in Racket

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

Rewrite the schema code in OCaml?

(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

Integer fraction numbers in the schema

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

emacs `racket-mode` REPL no loading recognition procedures

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

Create lists from lists

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

Result of communication of a method invocation on TCP

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

How to convert the port to a chain and list in the racket?

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->

When to use `form:` in Typed Racket?

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

decent mean of nested definition in the scheme

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

Diagram how to define var in so condition

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:...

Cond Si And Or In Racket

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

Recursive exponentiation racket programming

#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

binary trees seeking inside

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

Scheme Scoping (set and leave)

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

using structure definitions

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

the implementation of the binary search tree in the schema

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

How to do the opposite of the format?

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