Skip to content

Fridge, The Game

Jayson Harshbarger edited this page Apr 17, 2016 · 7 revisions
fridge-game:
  [
    cls
    [
      'You are in a fridge. What do you want to do?'
      '1. Try to get out.'
      '2. Eat.'
      '3. Die.'
    ]
    println: foreach
    {
      1: ['You try to get out. You fail. You die.']
      2: [
        'You eat. You eat some more.'
        'Damn, this food is tasty!'
        'You eat so much you die.'
      ]
      3: ['You die.']
    }
    prompt
    @
    dup null?
    [ drop [ 'Did not understand.' ] ]
    when
    '' <<
    'Play again? write y if you do.' <<
    println: foreach
    prompt
    'y' =
      [ fridge-game ]
      [ 'Thanks for playing.' println clr ]
    branch
  ];

fridge-game

Translated from the source at Happy Learn Haskell Tutorial Vol 1

Clone this wiki locally