Our First Computer Programs

(Section 1.1)

Hello, World!

Type this into your Console:

cat("Hello, World!")

Then press Enter. You should get:

## Hello, World!

That Was Our First Computer Program!

Computer Program

A sequence of instructions that performs a specific task when executed by a computer.

  • The above is a definition.
  • Definitions are at the end of each Chapter.
  • You must study and learn them (for Quizzes)

About cat()

  • cat() is a function
  • It prints whatever it is given to the Console, pretty much “as is”
  • You can learn more about cat with: help(cat)
  • Or with ?cat
  • (But R’s Help isn’t very helpful for you, yet!)

Strings

“Hello World!” is a string.

String

A value in a computer program that constitutes text (as opposed to numbers or some other type of data).

cat() can process strings. Strings are delimited by quote-marks.

Delimiter

A character in a programing language that is used to mark the beginning and/or end of a value.

Numbers, too!

  • cat() can also process numbers to the console.
  • It evaluates numerical expressions, first.

Try:

cat(2+2)
4

Interactive Mode

We are working in interactive mode.

Interactive Mode

A type of engagement between a human and a computer in which the computer prompts the humand for data and/or commands and may respond with output that the human can read and/or interpret.

The > in the Console is the prompt.

REPL

Read-Evaluate-Print Loop

An interactive cycle in which the R-interpreter reads an expression from the console, evaluates it, and prints out the value to the console.

Printing to the Console

You don’t need a cat() command to see a value.

"Hello, World!"
[1] "Hello, World!"
2 + 2
[1] 4

(But there is some odd “extra” processing.)