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
1
vote
1 answer

Evaluation of {with {x 3} {+ x x}} from page 76 in PLAI

I am studying PLAI's Chapter8 "Implementing Laziness", and finished the following CFAE/L: (define-type CFAE/L [num (n number?)] [add (lhs CFAE/L?)(rhs CFAE/L?)] [id (name symbol?)] [fun (param symbol?)(body CFAE/L?)] …
abelard2008
  • 1,984
  • 1
  • 20
  • 35
0
votes
1 answer

How to get the arguments of an instance of a Scheme define-type?

I have a stripped-down define-type of a function definition: (define-type FunDef (fundef (fn-name symbol?))) Here is a function definition which satisfies the define-type: (fundef 'f) How do I get the name of the function? For the example I…
Roger Costello
  • 3,007
  • 1
  • 22
  • 43
0
votes
0 answers

Nesting 'define' functions in another function in PLAIT, racket

Is it possible to define function inside another function in plait? When I do it in Racket it works well but in plait I keep getting errors. Here is an example: (define (fact n) (define (it-fact n) (if (= n 1) n (* n…
0
votes
0 answers

How to get the Racket command line to display an expression that is preceded by a backtick?

Scheme (Racket) newbie here. I am reading this book: Programming Languages Application and Interpretation by Shriram Krishnamurthi. I installed the plai package. The book has this define-type on page 6: (define-type AE [num (n number?)] [add…
Roger Costello
  • 3,007
  • 1
  • 22
  • 43
0
votes
1 answer

Must a colon separate an id and a type? Is a type with a question mark no longer acceptable?

Scheme (Racket) newbie here. I am reading this book: Programming Languages Application and Interpretation by Shriram Krishnamurthi. I installed the plai-typed package. The book has this define-type on page 6: (define-type AE? [num (n number?)] …
Roger Costello
  • 3,007
  • 1
  • 22
  • 43
0
votes
1 answer

Sort a list in Racket based on the operator

How can I sort and merge two lists based on the operator in Racket-Plait? > ascending, < descending order. This is what I have so far, but I do not have any idea what to do next. (define (merge [op : (Number Number -> Boolean)] …
0
votes
1 answer

How would I return a list that takes two lists and associates them with the contents in that list together in plait language for Racket?

I'm working on a problem that has me using Racket with plait language and I'm trying to get a program that takes two lists and associate them together like this. I am relatively new to Racket and the plait language. '(a b c d) and '(1 2 3…
0
votes
2 answers

Defining a Tree in LISP (Racket)

I'm trying to define a tree using Racket's #plai language, though I'm struggling a bit when it comes to creating the tree through an "add-node" function. The define-type I'm using goes like this: (define-type BBT [empty] [leaf (elem number?)] …
0
votes
1 answer

plai-typed: Nested structures using define-type in plai-typed DrRacket

I tried to write simple pattern matcher in DrRacket using #lang plai-typed as follows: #lang plai-typed (define-type Activity [kind (type : string) (description : string)] ) (define-type Hacktivity [activity1 (activity : Activity)] …
giribal
  • 19
  • 3
0
votes
1 answer

#lang plai racket multiplier function

I am working on a project to get us used to the plai-typed language for use in a programming languages course. I have been stuck on one question that's really bugging me (finished all the rest with no problem). We are to take this datatype…
Christophorus
  • 154
  • 12
0
votes
1 answer

Scheme Racket Shadowed variable checking

I need function to check is variable shadowed or not? Function should return #t or #f based on that is variable shadowed or not. I used DrRacket for implementing code (#lang plai). So far, I have this... #lang plai (define-type WAE [num (n…
vlada
  • 167
  • 15
0
votes
5 answers

how to write scheme function that takes two lists and return one list like this

how to implement this function if get two list (a b c), (d e) and return list (a+d b+d c+d a+e b+e c+e) list element is all integer and result list's element order is free I tried this like (define (addlist L1 L2) (define l1 (length L1)) …
user77292
  • 3
  • 2
1
2