Skip to content

Racket code runs but sometimes does not produce output. #83

@fuxoft

Description

@fuxoft

I ran this exactly same code several times (preceded by ./run racket):

#lang racket
(struct item (weight value) #:transparent)
(define (maximum-value maximum-weight items)
  (for/fold ([maxval 0] #:result maxval) ([combo (in-combinations items)])
    (values (if (<= (apply + (map item-weight combo)) maximum-weight)
      (let ([curval (apply + (map item-value combo))])
        (if (> curval maxval) curval maxval)) maxval))))
(display (format "max value: ~s" (maximum-value 10 (list (item 5 10) (item 4 40) (item 6 30) (item 4 50)))))

At first it produced the correct output (max value: 90) but afterwards it repeatedly said "Your racket(8.3.0) code ran without output".

Again, it was the EXACT same code.

Now, even even the following trivial code:

#lang racket
(display "hello")

...produces no output, only the messge "Your racket(8.3.0) code ran without output".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions