Add visual code block demarcations to sloum's article.
This commit is contained in:
parent
fae524911c
commit
7c3fab0dc8
|
@ -181,9 +181,11 @@ them since passing in paths to files or other input will quickly become useful.
|
||||||
I do not know much about the Windows command line, so from here on I will be
|
I do not know much about the Windows command line, so from here on I will be
|
||||||
talking about Linux/BSD/OSX. If you enter:
|
talking about Linux/BSD/OSX. If you enter:
|
||||||
|
|
||||||
|
---
|
||||||
cd ~
|
cd ~
|
||||||
mkdir programming_practice
|
mkdir programming_practice
|
||||||
cd programming_practice
|
cd programming_practice
|
||||||
|
---
|
||||||
|
|
||||||
You will move directories to your home directory. The program `cd` takes a file
|
You will move directories to your home directory. The program `cd` takes a file
|
||||||
path as an argument. In this case the `~` is something the shell (the actual
|
path as an argument. In this case the `~` is something the shell (the actual
|
||||||
|
@ -193,7 +195,9 @@ home folder called `programming_practice` and then `cd` into it.
|
||||||
|
|
||||||
You can always go directly to this folder with:
|
You can always go directly to this folder with:
|
||||||
|
|
||||||
|
---
|
||||||
cd ~/programming_practice
|
cd ~/programming_practice
|
||||||
|
---
|
||||||
|
|
||||||
Then you can run `ls` to see any files or subfolders you may want to work on/in.
|
Then you can run `ls` to see any files or subfolders you may want to work on/in.
|
||||||
|
|
||||||
|
@ -255,15 +259,19 @@ type into a file for each of the three languages I recommended above:
|
||||||
Create a file named `hello.py` in the current directory (`nano hello.py`, for
|
Create a file named `hello.py` in the current directory (`nano hello.py`, for
|
||||||
example) and enter the following text:
|
example) and enter the following text:
|
||||||
|
|
||||||
|
---
|
||||||
def say_hello():
|
def say_hello():
|
||||||
name = input("What is your name? ")
|
name = input("What is your name? ")
|
||||||
print("Hello " + name)
|
print("Hello " + name)
|
||||||
|
|
||||||
say_hello()
|
say_hello()
|
||||||
|
---
|
||||||
|
|
||||||
Then run the following in your terminal/shell:
|
Then run the following in your terminal/shell:
|
||||||
|
|
||||||
|
---
|
||||||
python3 ./hello.py
|
python3 ./hello.py
|
||||||
|
---
|
||||||
|
|
||||||
If it doesn't work, make sure you have Python 3 installed (type `python3
|
If it doesn't work, make sure you have Python 3 installed (type `python3
|
||||||
--version` at the shell and see if you get a Python version number printed. It
|
--version` at the shell and see if you get a Python version number printed. It
|
||||||
|
@ -279,6 +287,7 @@ the file is using the `cd` command. Then try running the program again.
|
||||||
|
|
||||||
Create a file named `hello.lua` and enter the following text:
|
Create a file named `hello.lua` and enter the following text:
|
||||||
|
|
||||||
|
---
|
||||||
function say_hello()
|
function say_hello()
|
||||||
io.write("What is your name? ")
|
io.write("What is your name? ")
|
||||||
io.flush()
|
io.flush()
|
||||||
|
@ -287,10 +296,13 @@ function say_hello()
|
||||||
end
|
end
|
||||||
|
|
||||||
say_hello()
|
say_hello()
|
||||||
|
---
|
||||||
|
|
||||||
Then run the following in your terminal/shell:
|
Then run the following in your terminal/shell:
|
||||||
|
|
||||||
|
---
|
||||||
lua ./hello.lua
|
lua ./hello.lua
|
||||||
|
---
|
||||||
|
|
||||||
If it doesn't work, make sure you have Lua installed (type `lua -v` at the
|
If it doesn't work, make sure you have Lua installed (type `lua -v` at the
|
||||||
shell, if you get a version number printed then you are good to go, if not then
|
shell, if you get a version number printed then you are good to go, if not then
|
||||||
|
@ -310,6 +322,7 @@ Create a directory for the program by running `mkdir go_hello && cd go_hello` at
|
||||||
your shell/terminal. Then create a file named `main.go` and enter the following
|
your shell/terminal. Then create a file named `main.go` and enter the following
|
||||||
text:
|
text:
|
||||||
|
|
||||||
|
---
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -322,11 +335,14 @@ func main() {
|
||||||
fmt.Scanln(&name)
|
fmt.Scanln(&name)
|
||||||
fmt.Printf("Hello %s", name)
|
fmt.Printf("Hello %s", name)
|
||||||
}
|
}
|
||||||
|
---
|
||||||
|
|
||||||
Then run the following in your terminal/shell:
|
Then run the following in your terminal/shell:
|
||||||
|
|
||||||
|
---
|
||||||
go build
|
go build
|
||||||
./go_hello
|
./go_hello
|
||||||
|
---
|
||||||
|
|
||||||
You may notice that running the program is a little different here. We call `go
|
You may notice that running the program is a little different here. We call `go
|
||||||
build` first. This compiles the program into an executable file. We then run
|
build` first. This compiles the program into an executable file. We then run
|
||||||
|
|
Loading…
Reference in New Issue