r/Racket • • Jul 06 '21

book Don’t Teach Coding: Until You Read This Book

0 Upvotes

“The definitive resource for understanding what coding is, designed for educators and parents”

Don’t Teach Coding: Until You Read This Book


r/Racket • • Nov 28 '19

Just because its inventors surrounded some pseudocode with an arbitrary amount of parentheses doesn’t mean they get to call Racket a real language.

Thumbnail
ubyssey.ca
0 Upvotes

r/Racket • • Aug 23 '26

language Are there languages like this?

Thumbnail reddit.com
2 Upvotes

Simple syntax tho!


r/Racket • • Nov 01 '22

question Adding the element at the end of the list efficiently

0 Upvotes

It has always annoyed me that the operation of adding an element to the end of a list in Scheme is an "expensive" one, (unlike the operation of adding to the beginning of a list).

Of course, in standard Scheme, there is always a way to get over it, like this:

(define (list-builder)
  (let ((mylist '())
        (lastcell '()))
    (lambda (m)
      (case m
        ((append) (lambda (x)
                    (cond
                      ((null? mylist)
                       (set! mylist (cons x '()))
                       (set! lastcell mylist))
                      (else
                       (let ((newcell (cons x '())))
                         (set-cdr! lastcell newcell)
                         (set! lastcell newcell))))))
        ((get) (lambda () mylist))))))

Now we can do this:

> (define mylist (list-builder))
> ((mylist 'append) 1)
> ((mylist 'append) 2)
> ((mylist 'append) 3)
> ((mylist 'get))
> (1 2 3)

But when we try to do the same in Racket, we can't because Racket doesn't support mutable lists.

Ok: truth be told, racket has mcons, mcar set-mcar!, set-mcdr!, etc, but in Racket those mutable lists are completely separate from regular lists and cannot be interchanged. This means that none of the functions for working with "classic" lists can be used over mutable lists, which really sucks!

I don't know about you, but to me this is a totally strange decision by the creators of Racket, because, as far as I know, the idea of Scheme is not only to be a functional language, but also to have its imperative side, too. I don't understand why Racket gets away with it and discourages the use of mutable list wherever it can?


r/Racket • • Mar 09 '20

question Why using a different programming language rather than using any famous language ?

0 Upvotes

r/Racket • • Dec 11 '21

question Why does this return false in racket??

0 Upvotes

(string=? "design" "tinker")


r/Racket • • Aug 18 '19

Brilliant!

Post image
0 Upvotes

r/Racket • • Mar 27 '24

ephemera Newest 'racket' Questions on stackoverflow.com

Thumbnail
stackoverflow.com
0 Upvotes

r/Racket • • Jun 17 '15

a little help...

0 Upvotes

I need help to design a function that consumes two images and produces true if the first is larger than the second. but they have to be primitive images (triangles and the like)... please help me, cause I am totally lost on how to do this, I am not sure how to do this T_T is due to me being new at this


r/Racket • • Feb 15 '19

Can someone help me with some simple Racket Design HW?

0 Upvotes

CSAS 1114: Introduction to Program Design I

Homework 2: Greeting

DUE Friday, Feb 15th by 11:59pm

Overview

Write a function that takes time in military format and the user’s first name.

a) The function should create appropriate greeting message that includes user’s name.

b) If the number was not in the right range, print: “I don’t understand this time! Are you in another dimension?”

c) Call the function for following inputs:

a. Your name, 1605

b. Alien, 20543

d) Use check-expect to test your program

Note 1: Follow this format for greeting:

Good morning = 0:00 - 12:00

Good afternoon = 12:01 - 17:00

Good evening = 17:01 - 24:00

Note 2: Here is the time in military format

Military – Regular

Military – Regular

0001 – 12:01 am

1300 – 1:00 pm

0100 – 1:00 am

1400 – 2:00 pm

0200 – 2:00 am

1500 – 3:00 pm

0300 – 3:00 am

16:00 – 4:00 pm

0400 – 4:00 am

17:00 – 5:00 pm

0500 – 5:00 am

1800 – 6:00 pm

0600 – 6:00 am

1900 – 7:00 pm

0700 – 7:00 am

2000 – 8:00 pm

0800 – 8:00 am

2100 – 9:00 pm

0900 – 9:00 am

2200 – 10:00 pm

1000 – 10:00 am

2300 – 11:00 pm

1100 – 11:00 am

2400 – 12 Midnight

1200 - Noon

Example:

Input: Justin, 200

Sample Output: Good morning, Justin!

Submission

Submit your DrRacket code via blackboard under lab “Greeting”.

Guideline:

Program should begin with a header comment that provides the name of the homework, the name of the author, the date, and a short description of the program.

I created these conditions so far:

(define (greeting mtime name)

(cond

[(and (<= 0 mtime) (<= 1200 mtime)) "Good Morning"]

[(and (< 1201 mtime) (<= 1700 mtime)) "Good Afternoon"]

[(and (< 1701 mtime) (<= 2400 mtime)) "Good Evening"]

[else "I don’t understand this time! Are you in another dimension?"]))

But I am confused about how to use string-append and how to call these conditions. If I made a mistake above, please feel free to correct it. Thank you!


r/Racket • • Mar 15 '23

question Empty list

0 Upvotes

(define (sn-empty)

(sn-empty)

'())

I have been trying to print an empty list.

The input:

> sn-empty

output:

()

Please explain what I am doing wrong in the code above.


r/Racket • • Oct 23 '19

Racket of Fasebook..

0 Upvotes

A “DrRacket” group is present on FB, you’re welcome!

Someone told me it was a bad idea but I did it anyway, there’s 146 members as of now.


r/Racket • • 6d ago

homework Help with Intro to CS test - tomorrow

0 Upvotes

I've been having some issues in understanding concepts in CS, and although I've gone to tutoring and gotten my grade up a bit, knowing and understanding base concepts would help significantly, especially since we do cover material very quickly. My test tomorrow is exclusively on recursion, specifically tail and non-tail. I've been able to complete non-tail recursions correctly for the study guide given, but am having a bit of a harder time with the tail recursions (below). I also need to go over if and cond statements, which I can do correctly but don't have an entirely firm grasp of, and the basic syntax - things like memorizing quotient, remainder, modulo etc. The questions are :

7. Write a tail-recursive function sum-of-squares, where a <= b, that computes: a ^ 2 + (a + 1) ^ 2 + (a + 2) ^ 2  + ... + b ^ 2. You may write a helper function.

Write a procedure that computes the sum of the squares of every integer from a to b:

a² + (a+1)² + (a+2)² + … + b²

For example, (sum-of-squares 2 4) computes 2² + 3² + 4² = 4 + 9 + 16 = 29.

Your solution must be tail-recursive: the recursive call must be the very last thing the procedure does, with nothing left to compute after it returns. 

a. The helper: (sum-of-squares-helper a b acc)

b. The wrapper: (sum-of-squares a b), the wrapper should contain no recursion of its own.

Examples:

(sum-of-squares 1 1) => 1
(sum-of-squares 5 5) =>  25
(sum-of-squares 1 3) => 14
(sum-of-squares 2 4) => 29

8. Write a tail-recursive function that computes x ^ n (x to the power of n). Name your function power-n. 

For example, (power-n 2 3) computes 2 × 2 × 2 = 8.

Your solution must be tail-recursive.

a. The helper: (power-helper x n acc)

b. The wrapper: (power-n x n). The wrapper should contain no recursion of its own.

Examples:

(power-n 2 0)   => 1
(power-n 2 1)   => 2
(power-n 2 3)   =>  8

I can answer these on my own, so please do not give the answers, but provide a very basic explanation - visual if possible - and label each component. Thank you!


r/Racket • • Oct 09 '22

homework Function that prints first and last character, this is example of how it should work. I am completely new to racket and spend there like 5 hrs,so every hint or help is appreciated!

Post image
1 Upvotes

r/Racket • • Aug 31 '26

question I'm interested in learning all about the racket programing language

Thumbnail reddit.com
2 Upvotes

r/Racket • • Oct 16 '22

question Create list of lists.

0 Upvotes

Hi, how can I create list of lists. Method (append '() '(1) '(1 1 1)) return list of ints, but I need something like this: ('() '(1) '(1 1 1))


(define/contract (generate numRows)

(-> exact-integer? (listof exact-integer?))

(define (pascal-triangle n)

(define (build-row r)

(list (if (null? (cdr r))

(car r)

(list (+ (car r) (cadr r)) (build-row (cdr r))))))

(let build-triangle (\[lst-storage '()\] \[lst '(1)\] \[n2 n\])

(if (eq? n2 0)

lst-storage

(build-triangle

(append lst-storage lst)

(flatten (list (first lst) (build-row lst)))

(sub1 n2)))

)

)

(pascal-triangle numRows)

)

(generate 5)

r/Racket • • Aug 14 '18

I2P communication

0 Upvotes

I am in the search of package/code for creating I2P application.


r/Racket • • May 28 '22

question Can I set the variable x to equal sqr?

0 Upvotes

Is it possible to set x equal to the built-in function sqr? If so what would that look like?

Edit: How would you make a string consisting of "sqr" perform it's mathematical function instead?


r/Racket • • Mar 25 '20

homework FOR LOOP

2 Upvotes

i need to write a for loop function that iterates over a list and counts the number of items in the list

Please be kind and help me

if you could tell me how to do it would be very much appreciated.


r/Racket • • Feb 13 '19

How do I reverse a list in racket without using the built-in function and using basic recursion?

0 Upvotes

r/Racket • • Sep 11 '18

How do I set a variable to be a value?

1 Upvotes

I tried (define x 3) but that isn't working. I tried other versions of that but still no cigar.


r/Racket • • Dec 26 '14

Quora question - Would someone create some more Racket tutorials?

Thumbnail
quora.com
0 Upvotes

r/Racket • • Nov 28 '24

homework Programming help

Post image
0 Upvotes

r/Racket • • Aug 09 '20

Controversial opinion: Racket > scheme.

3 Upvotes

I’m not saying Scheme is bad - Scheme is great. Just that Racket has a lot of extras, both in the language and surrounding tools.

e.g. did you know raco pkg migrate 7.7 will move everything you had installed in 7.7 into your current version(7.8).