Questions tagged [plai]

The Programming Languages: Application and Interpretation textbook and related languages

Programming Languages: Application and Interpretation (PLAI) is a textbook written by Shriram Krishnamurthi from Brown University. It uses a number of custom languages built on Racket.

Resources

27 questions
4
votes
1 answer

"application: not a procedure" in binary arithmetic procedures

I have a simple Racket definition for multiplying binary numbers together. It uses a well-tested "addWithCarry" definition that takes three parameters: two lists and a carry digit and returns the binary sum. The binary numbers are represented as…
smirciat
  • 105
  • 1
  • 1
  • 6
3
votes
0 answers

Writing a parser in Racket #lang plai

I need to write a parser in racket for this abstract syntax: ;; ::= ;; | {distribution *} ;; | {uniform } ;; | {+ } ;; | {- } ;; | {* } ;; | {with { } } ;; …
3
votes
0 answers

Plai multiple values

my task is to make this to test to run: (test (run "{+ {2 1} {3 4}}") '(5 6 4 5)) (test (run "{+ {- {+ 1 3} 2} {10 -10}}") '(12 -8)) The source code i have so far looks like that #lang plai (require (for-syntax racket/base) racket/match…
3
votes
2 answers

Racket - lang plai - define-type and type-case explanations

Can someone try and explain these two functions: "define-type" and "type-case" in the PLAI scheme in racket? I'm a noob programmer and I don't really understand the documentation on the racket website. If anyone could provide examples, it would…
indianhottie
  • 323
  • 3
  • 11
3
votes
3 answers

how to resolve this error "reference to an identifier before its definition: with"

I am studying "Programming Languages: Application and Interpretation" and I can run the first two chapters' examples in DrRacket 5.2.1 after executing #lang plai. but when I typed the 3rd chapter's first example as below: (with (x 5) (+ x x)) I got…
abelard2008
  • 1,984
  • 1
  • 20
  • 35
2
votes
1 answer

How to give a specific type of function as a parameter in Racket/Plait?

I am writing a function that takes in a function and a list as parameters. The parameter function and the list must have the same type of values. How do I ensure that? I have tried: (define ( (func -> 'a) [lst : (Typeof 'a)]) ....) However, I…
N.Ali
  • 35
  • 2
  • 7
2
votes
1 answer

racket in geiser: switch language in live REPL to plai-typed

I've seen hits all around this basic issue, but nothing to help with, in particular, plai-typed. So, I can start a racket REPL in geiser, then type (require typed/racket) and it seems to take, i.e., I'm ready to go with basic typed racket. Normally,…
147pm
  • 2,137
  • 18
  • 28
2
votes
1 answer

cons to empty list of type not working

I'm working through the Programming Languages: Application and Interpretation book chapter 6 http://cs.brown.edu/courses/cs173/2012/book/From_Substitution_to_Environments.html I've applied a fix as described in the book but the cons is not adding…
Mick Duprez
  • 115
  • 2
  • 10
2
votes
1 answer

Converting BNF grammar to s-expression

I defined a grammar called msl #lang plai-typed (define-type msl [msl-num (n : number)] [msl-add (l : msl) (r : msl)] [msl-mul (l : msl) (r : msl)] [msl-sub (l : msl) (r : msl)] [msl-pow (l : msl) (r : msl)] [msl-error (s : string)] …
JayGatsby
  • 1,541
  • 6
  • 21
  • 41
2
votes
2 answers

how to edit and run PLAI code in Emacs with DrRacket 5.2.1

I am studying PLAI, Now I have already run chapter 3's code in DrRacket (with #lang plai), but I am a newbie in DrRacket. Can I edit and run the code only in Emacs?
abelard2008
  • 1,984
  • 1
  • 20
  • 35
1
vote
0 answers

Racket Install plai-typed

i have some issue to install the package plai-typed on racket. Here is the error: Resolving "plai-typed" via http://download.racket-lang.org/releases/6.3/catalog/ Resolving "plai-typed" via http://pkgs.racket-lang.org Using …
1
vote
1 answer

plai-typed : how to define function type?

I'm playing with plai-type language. I have a function which should consume a predicate function (returning true or false) and a list of items. My code looks like: (define-type-alias IndexT (listof IndexItemT)) (define (index->filter pf [index :…
Jaro
  • 3,799
  • 5
  • 31
  • 47
1
vote
1 answer

RACKET: Require a pair type function

I'm making a program in the plai-typed language, however I want to use the functions 'car' and 'cdr' (require (typed-in racket (car : (pair -> any/c)) (cdr : (pair -> any/c)))) However it gives me the error pair:bad…
user5690367
1
vote
1 answer

Demonstrating that an expression has a type

I am working on a practice sheet for a final tomorow and I am a bit confused trying to figure out what the question is asking and how to resolve it. I wanted to check here and see if the good people of stack overflow can help me resolve it. The…
Christophorus
  • 154
  • 12
1
vote
2 answers

what steps included in the program's executing in Chapter9's first program of PLAI

In PLAI's chapter9 "Understanding Recursion", at the beginning, there is an example factorial: (with (fac (fun (n) (if0 n 1 (* n (fac (+ n -1)))))) At page 90, the author said "Before you…
abelard2008
  • 1,984
  • 1
  • 20
  • 35
1
2