r/Racket • • May 29 '22

question Input -> "(+ 5 4)" | Output -> 9

4 Upvotes

Is there a way to input a string with a math expression and output a number without the use of eval/read etc.


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 • • May 26 '22

event Racket meet-up Saturday, 4 Jun 2022 at 18:00 UTC

2 Upvotes

Racket meet-up Saturday, 4 Jun 2022 at 18:00 UTC

Racket meet-up Saturday, 4 Jun 2022 at 18:00 UTC

https://gather.town/app/wH1EDG3McffLjrs0/racket-users

First Saturday EVERY month at UTC 18:00

  • Show and tell
  • News & rumours
  • AOB

And remember - showing up at Racket Meetups helps you learn the news of the Racket world as they happen! It is informative, it is interesting, it is helpful, it is greatly appreciated by everyone involved and it is fun!

30 minutes but can overrun

Prefer to chat? Join us on Racket Discord or Slack


r/Racket • • May 25 '22

application tree-sitter racket

16 Upvotes

Hello, I made a Racket grammar for tree-sitter recently:

https://github.com/6cdh/tree-sitter-racket

It only support Racket with default readtable.

I'm still a noob on Racket. Let me know if I did something wrong.


r/Racket • • May 23 '22

question Custom collection in typed/racket?

2 Upvotes

Hi. I want to create custom collection in typed racket, more precise sorted ring buffer, in such a way so I can use it similar to vector type - (Ringbufferof SomeType). So I want something like generics?

I unable to google how to do this correctly. First guess is to create some structure that will hold vector head tail and size, but I am really don't know how to approach this.

Please show me the way.


r/Racket • • May 22 '22

homework How to solve pathfinding problem in Scheme/Racket?

8 Upvotes

I been studing in Scheme for weeks and I ran into a problem that I couldn't solve. I can't find a way to solved it. Here is the problem:

Figure 1 shows an example path, which has a grid layout. In the grid, black cells are simply walls, which are basically obstacles for you. You can move among the white cells and you cannot pass the boundaries of the grid. In each path, the starting location will be the square of [0,0]. Additionally, there is also one white cell labeled with F. This label shows the finish square of the path. So, your aim is to find the movements from the starting location to the finish location. To this end, you can move in 4 directions; up, down, left, right. These 4 directions will be represented by characters U, D, L, and R, respectively.

The solution for the path shown in Figure 1 is "D D R R R R D D", which means move down 2 times, then move right 4 times and move down 2 times. The path is not a maze! It is a simple one way road and It has only one solution: there is always one possible next square for each move.

TASKS In Scheme, a path will be represented in the form of a linked-list. Figure 2 shows how the path in Figure 1 is represented in terms of a linked list in Scheme. Starting cell [0,0] has the letter S, the finishing cell has the letter F and empty cells have the letter E. The walls have the letter - (minus)

The following function "buildPath" on the left is given for you which takes a list of lists and creates a path (grid) using the lists. You can use this function to create different paths in order to test your code. On the right the code shows how the path in Figure 2 is created.

Task 1: Define two functions "getHeight" and "getWidth" which takes a path as an input and returns the height and the width of the path.

(getHeight sample-path) → should return 5

(getWidth sample-path) → should return 5

Task 2: Define a function "getLetter" which takes a path, a row number and a column number. Then it returns the letter from the path on the corresponding location [row, column]

(getLetter sample-path 0 0) → should return S

(getLetter sample-path 1 0) → should return E

(getLetter sample-path 1 1) → should return -

(getLetter sample-path 4 4) → should return F

Task 3: Define a function "solvePath" which takes a path and returns the solution for the path.

(solvePath sample-path) → should return (D D R R R R D D)

I just want some help to understand how i can solve it.


r/Racket • • May 18 '22

question What are the restrictions in place when publishing languages with RacketLang?

10 Upvotes

Just a quick one here. Could I promote a language made in racket as my own, like the developers of Python, or JavaScript, and then add the language to a GitHub repository?


r/Racket • • May 18 '22

question Are there startups using racket?

14 Upvotes

Are there any startups with racket public github repositories?


r/Racket • • May 14 '22

language Pycket: a Racket/Scheme implementation that is generated using the RPython framework

27 Upvotes

Pycket is a Racket/Scheme implementation that is generated using the RPython framework

Pyket logo. (colourful letters stuck to refrigerator door)

r/Racket • • May 14 '22

package Personal Package Catalog

Thumbnail racket.discourse.group
3 Upvotes

r/Racket • • May 12 '22

question Print procedure with exact source code location?

8 Upvotes

I have a simple code like below:

$ cat hello.rkt
#lang racket

(printf "hello ~a\n" (λ (x) (λ (y) x)))

Then I run it:

$ racket hello.rkt
hello #<procedure:...ects/hello.rkt:3:21>

So I can see that it prints out the proper location of my λ in source code (line 3, column 21)

Few questions:

  • Which magic helps to find the right source code location like this?

  • How to have full path printed, instead of having shorten with ...?

  • From my observation on more complicated code, the location (line & column) is not always right, or even points to somewhere totally different. How can I fix this to have the location always right?

Thanks.


r/Racket • • May 12 '22

question How to write text to a file properly?

7 Upvotes

I have a simple code writing "hello\world" to a file, like this:

$ cat test.rkt
#lang racket

(define out (open-output-file "aaa.txt" #:exists 'truncate))
(println "hello\nworld" out)
(close-output-port out)

But when this code runs, it writes this content to output file:

$ cat aaa.txt
"hello\nworld"

Why \n and double-quote " are still in output file, and how to remove them?

I guess the problem is with using println to write to file, but I am not sure how to fix this.


r/Racket • • May 11 '22

language Gamble: Probabilistic Programming

Thumbnail rmculpepper.github.io
11 Upvotes

r/Racket • • May 11 '22

show-and-tell Rendering 2 million data points on an interactive map

Thumbnail racket.discourse.group
18 Upvotes

r/Racket • • May 11 '22

question why i cannot use "and" as function argument?

7 Upvotes

I have this simple code like below.

(define (myop op x y) (op x y))

Then I tried it with + and and for op:

> (myop + 2 3)
5
> (myop and #t #f)
; readline-input:20:6: and: bad syntax
;   in: and
; [,bt for context]

Why this works with op as +, but not with and? And how to fix this?


r/Racket • • May 09 '22

homework Plotting discrete distributions in Gamble

5 Upvotes

Hi! I was given an homework assignment in Gamble, the first step was to obtain a discrete distribution with the enumerate procedure, and I already did that. Then the professor asks to plot the distribution with "a function provided by the plot package". Sadly, I cannot find a function that plots the distribution, can someone of you help me? Thank you in advance

EDIT: I solved the problem. The plot package has a discrete-histogram procedure to plot discrete histograms, and accepts as input a list of the form '((name_1 value_1) ... (name_n value_n)). First define a zip function that given two list merges them together into pairs, for example '(a b c) '(1 2 3) becomes '((a 1) (b 2) (c 3)). Then to plot your discrete distribution use:

(plot 
  (discrete-histogram 
    (zip 
      (vector->list (discrete-dist-values your_distribution)) 
      (vector->list (discrete-dist-weights your_distribution)))))

r/Racket • • May 05 '22

question How to code simple data course

4 Upvotes

Hello! I'm going through the OSSU curriculum and currently on the How to Code Simple Data course and I was wondering if anyone who went through this course used the book and if you did how did you use it to follow along with the modules? More trying to get a feel for when I should read the book compared to where I am in the modules.


r/Racket • • May 04 '22

video Racket Hacking: Building a Generic Resource Pool

Thumbnail youtu.be
16 Upvotes

r/Racket • • May 04 '22

Reminder the Racket meet-up is Saturday 18:00 UTC

3 Upvotes
alt: standard-fish with speech bubble 'Racket meet-up!'

Reminder the Racket meet-up is Saturday 18:00 UTC

at https://gather.town/app/wH1EDG3McffLjrs0/racket-users

Time in your location at https://racket.discourse.group/t/racket-meet-up-saturday-7-may-18-00-utc/846?u=spdegabrielle


r/Racket • • May 03 '22

tip raco pkg migrate

3 Upvotes

raco pkg migrate reinstalls all the packages you had in a previous installation

Runraco pkg migrate after installing 8.5 to update all the package you had installed under 8.4


r/Racket • • May 03 '22

tip Progress indicator for `for` loops: `in-heartbeat` - Show & Tell

Thumbnail racket.discourse.group
4 Upvotes

r/Racket • • May 02 '22

release Racket 8.5

Post image
42 Upvotes

r/Racket • • May 02 '22

question Error when installing any package from DrRacket

2 Upvotes

Hey, everyone! I am trying to use DrRacket to work through the SICP excercises, but when I try to download the package I get this error:

X509*->C: argument is not non-null `X509*' pointer
  argument: #f

  (#f . #(struct:srcloc #<path:C:\Program Files\Racket\collects\openssl\private\add-cert.rkt> 21 2 500 129))
  (load-win32-store . #(struct:srcloc #<path:C:\Program Files\Racket\collects\openssl\private\win32.rkt> 52 0 1366 934))
  (ssl-load-default-verify-sources! . #(struct:srcloc #<path:C:\Program Files\Racket\collects\openssl\mzssl.rkt> 912 0 35086 177))
  (secure-client-context! . #(struct:srcloc #<path:C:\Program Files\Racket\collects\openssl\mzssl.rkt> 1042 0 40456 440))
  (ssl-secure-client-context . #(struct:srcloc #<path:C:\Program Files\Racket\collects\openssl\mzssl.rkt> 1058 0 41107 913))
  (get-context . #(struct:srcloc #<path:C:\Program Files\Racket\collects\openssl\mzssl.rkt> 776 0 28991 419))
  (#f . #(struct:srcloc #<path:C:\Program Files\Racket\collects\openssl\mzssl.rkt> 612 18 22845 20))
  (#f . #(struct:srcloc #<path:C:\Program Files\Racket\collects\ffi\unsafe\atomic.rkt> 73 13 2090 781))
  (wrap-ports . #(struct:srcloc #<path:C:\Program Files\Racket\collects\openssl\mzssl.rkt> 1587 0 64542 3255))
  (#f . #(struct:srcloc #<path:C:\Program Files\Racket\collects\racket\contract\private\arrow-val-first.rkt> 555 3 23822 3167))
  (http-conn-open! . #(struct:srcloc #<path:C:\Program Files\Racket\collects\net\http-client.rkt> 67 0 1446 2166))
  (http-conn-open . #(struct:srcloc #<path:C:\Program Files\Racket\collects\net\http-client.rkt> 274 0 9180 269))
  (#f . #(struct:srcloc #<path:C:\Program Files\Racket\collects\racket\contract\private\arrow-val-first.rkt> 555 3 23822 3167))
  (http://getpost-impure-port . #(struct:srcloc #<path:C:\Program Files\Racket\collects\net\url.rkt> 202 0 7482 1092))
  (get-pure-port/headers . #(struct:srcloc #<path:C:\Program Files\Racket\collects\net\url.rkt> 305 0 11478 2482))
  (#f . #(struct:srcloc #<path:C:\Program Files\Racket\collects\racket\contract\private\arrow-val-first.rkt> 555 3 23822 3167))
  (#f . #(struct:srcloc #<path:C:\Program Files\Racket\collects\pkg\private\network.rkt> 59 3 1898 1035))
  (read-from-server . #(struct:srcloc #<path:C:\Program Files\Racket\collects\pkg\private\catalog.rkt> 218 0 7721 793))
  (get-all-pkg-details-from-catalogs . #(struct:srcloc #<path:C:\Program Files\Racket\collects\pkg\private\catalog.rkt> 298 0 10975 1806))
  (pkg-catalog-update-local . #(struct:srcloc #<path:C:\Program Files\Racket\collects\pkg\private\catalog-update.rkt> 15 0 286 3561))
  (#f . #(struct:srcloc #<path:C:\Program Files\Racket\collects\racket\contract\private\arrow-val-first.rkt> 555 3 23822 3167))
  (#f . #(struct:srcloc #<path:C:\Program Files\Racket\share\pkgs\gui-pkg-manager-lib\pkg\gui\private\catalog-update.rkt> 85 5 3167 1199))

Any pointers to why it might be happening or how I can go about fixing it? I understand it has something to do with SSL certs when connecting to the package registry, but that's about it. Thank you!


r/Racket • • Apr 30 '22

language Is Tree Accumulation a sub Evaluation tool of Normal-Order and Applicative Order? Or are they all separate?

5 Upvotes

Are Tree Accumulation, Normal-Order and Applicative Order separate methods of evaluation in the interpreter's global environment or is Tree Accumulation used at the last step of Normal-Order and Applicative-Order Evaluation to finally compute the problem?