Tracks
/
Factor
Factor
/
Exercises
/
Hello World
Hello World

Hello World

Tutorial Exercise

Introduction

“Hello, World!” will get you writing some Factor and familiarize yourself with the Exercism workflow. Completing it unlocks the rest of the Factor Track.

Watch our "Introduction to Hello, World" video to get started 👇

Instructions

The classical introductory exercise. Just say "Hello, World!".

"Hello, World!" is the traditional first program for beginning programming in a new language or environment.

The objectives are simple:

  • Modify the provided code so that it produces the string "Hello, World!".
  • Run the test suite and make sure that it succeeds.
  • Submit your solution and check it at the website.

If everything goes well, you will be ready to fetch your first real exercise.

Implementation notes

A Factor program is built from words, grouped into vocabularies.

Factor loads a vocabulary from a directory of the same name, so the hello-world vocabulary is the file hello-world.factor inside a hello-world/ directory.

: say-hello ( -- str ) … ; defines the word say-hello. The part in parentheses is its stack effect: nothing to the left of -- means it takes no input, and str to the right means it leaves one value (the name is only documentation, not a type). Everything between the stack effect and the closing ; is the body — the code that runs when the word is called.

The test suite calls say-hello and checks the value it leaves on the stack. Change the body so the word leaves "Hello, World!" instead, then run the tests.

Edit via GitHub The link opens in a new window or tab
Factor Exercism

Ready to start Hello World?

Sign up to Exercism to learn and master Factor with 47 concepts163 exercises, and real human mentoring, all for free.