Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MaisaMilena/3b17e7200eebdf95b5e316f1e784e536 to your computer and use it in GitHub Desktop.
Save MaisaMilena/3b17e7200eebdf95b5e316f1e784e536 to your computer and use it in GitHub Desktop.
def Car: [type] [color]
  [Car] [Horse] [Boat]
  (Car type color)

def Horse: [name]
  [Car] [Horse] [Boat]
  (Horse name)

def Boat:
  [Car] [Horse] [Boat]
  Boat


def describe_vehicle: [vehicle]
  let case_car    = [type] [color] &("Car with characteristics: ", &(type, color))
  let case_horse  = [name] &("Horse with name: ", name)
  let case_boat   = "Simple boat "
  (vehicle case_car case_horse case_boat )


def NPC: [question]
  [NPC] [Monster] [Vehicle-Seller]
  (NPC question)

def Monster: [str] [atk]
  [NPC] [Monster] [Vehicle-Seller]
  (Monster str atk)

def Vehicle-Seller: [vehicle]
  [NPC] [Monster] [Vehicle-Seller]
  (Vehicle-Seller vehicle)

def talk: [character]
  let case_npc      = [question] (anwser question) 
  let case_monster  = [str] [atk] &("I have the attributes: ", &(str, atk))
  let case_seller = [vehicle] (describe_vehicle vehicle)
  (character case_npc case_monster case_seller)

def anwser: [question]
  &(question, "NPC says: I'll write your question and call you later")

def main:
  let Car    = (Car "Jeep" "gray")
  let cavalo = (Horse "Cavalo")
  let barco  = Boat

  let npc      = (NPC "where is the market?")
  let monster  = (Monster 8 5)
  let seller   = (Vehicle-Seller Car) 

  (talk seller)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment