Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
reform-handbook
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JC Staudt
reform-handbook
Commits
9b0f2793
Unverified
Commit
9b0f2793
authored
4 years ago
by
minute
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into ci-setup
parents
952e733e
ce056774
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/source/tutorial.rst
+11
-11
11 additions, 11 deletions
src/source/tutorial.rst
with
11 additions
and
11 deletions
src/source/tutorial.rst
+
11
−
11
View file @
9b0f2793
...
...
@@ -30,7 +30,7 @@ What is Scheme?
Scheme is a programming language that looks like this:
.. code-block::
lisp
.. code-block::
none
(define (greet name)
(string-append "Hello " name "!"))
...
...
@@ -46,7 +46,7 @@ In Scheme, a pair of parentheses indicates one step of calculation. A function
name comes after the open parenthesis followed by arguments. Tokens are
reparated by spaces, tabs and newlines.
.. code-block::
lisp
.. code-block::
none
(define (square x)
(* x x))
...
...
@@ -63,19 +63,19 @@ Variables
To define a variable, use ``define``, followed by a **name** and a **value**.
.. code-block::
lisp
.. code-block::
none
(define red #xff0000)
To draw a pixel at the location ``20,30`` with the color we just defined, we will use ``put-pixel`` followed by **x**, **y** and our **color**.
.. code-block::
lisp
.. code-block::
none
(put-pixel 20 30 red)
A complete interscheme project that will draw 4 pixels to the screen might look something like:
.. code-block::
lisp
.. code-block::
none
(define red #xff0000)
(define yellow #xffff00)
...
...
@@ -98,7 +98,7 @@ A rectangle is made up of 4 lines, our function is named ``stroke-rect``, follow
The ``stroke-line`` function is something that comes with interscheme to help us draw lines.
.. code-block::
lisp
.. code-block::
none
(define (stroke-rect x y w h color)
(begin
...
...
@@ -109,7 +109,7 @@ The ``stroke-line`` function is something that comes with interscheme to help us
We can use our newly created function like so:
.. code-block::
lisp
.. code-block::
none
(define red #xff0000)
(define yellow #xffff00)
...
...
@@ -144,7 +144,7 @@ the result of the operation will be ``this`` if the second parameter is ``true``
, otherwise will be ``that``. In Scheme, true is indicated as ``#t``, and false
is indicated as ``#f``.
.. code-block::
lisp
.. code-block::
none
(define (min a b)
(if (< a b) a b))
...
...
@@ -154,14 +154,14 @@ Draw a pixel
To draw a single red pixel at ``30,30``:
.. code-block::
lisp
.. code-block::
none
(pixel-put 30 30 #ff0000)
You may also use a loop to draw a series of pixels. For example,
here's one way to put 50 pixels down in random positions:
.. code-block::
lisp
.. code-block::
none
(import (srfi 27))
(define (put-pixels? #t)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment