Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create values and functions tutorial #1512

Merged
merged 95 commits into from Nov 10, 2023
Merged

Create values and functions tutorial #1512

merged 95 commits into from Nov 10, 2023

Conversation

cuihtlauac
Copy link
Collaborator

@cuihtlauac cuihtlauac commented Aug 25, 2023

This is an intermediate level tutorial.

The main goal is to master the concepts of definition, scope and environment. It covers definitions of functional and non-functional values.

https://staging.ocaml.org/docs/values-and-functions

sabine added a commit that referenced this pull request Aug 29, 2023
data/tutorials/language/0lg_08_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_08_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_08_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_08_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_08_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_08_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_08_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_08_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_08_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_08_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_09_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_09_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_09_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_09_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_09_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_09_env.md Outdated Show resolved Hide resolved
data/tutorials/language/0lg_08_env.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@christinerose christinerose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few new comments/suggestions and a few that were outdated from before (just in case they were lost in the shuffle). If you didn't want to make those changes or it didn't clarify, we can work on them together if necessary.

cuihtlauac pushed a commit that referenced this pull request Sep 6, 2023
cuihtlauac pushed a commit that referenced this pull request Sep 6, 2023
sabine added a commit that referenced this pull request Sep 7, 2023
sabine added a commit that referenced this pull request Sep 7, 2023
sabine added a commit that referenced this pull request Sep 7, 2023

### Values

Like most functional programming languages, OCaml is an [expression-oriented programming language](https://en.wikipedia.org/wiki/Expression-oriented_programming_language). There are no [statements](https://en.wikipedia.org/wiki/Statement_(computer_science)), i.e., syntactical constructions made to produce some change of state. Variable [assignments](https://en.wikipedia.org/wiki/Assignment_(computer_science)) or [for loop](https://en.wikipedia.org/wiki/For_loop) are examples of statements. Computations triggered by OCaml are written as expressions. Once completed, they produce a value, which has a type. Here are a few examples of expressions, their type, and resulting values.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would phrase the difference between expressions and statements this way: the evaluation of a an expression yields a value, the evaluation of a statement yields an effect, i.e. a change of state. In many languages expressions can still yield effects and so the distinction between is not always clear cut. The same is true in OCaml where expressions and effects can be mixed.

@sabine sabine linked an issue Sep 15, 2023 that may be closed by this pull request
sabine added a commit that referenced this pull request Oct 5, 2023
sabine added a commit that referenced this pull request Oct 5, 2023
sabine added a commit that referenced this pull request Oct 9, 2023
sabine added a commit that referenced this pull request Oct 10, 2023
sabine added a commit that referenced this pull request Oct 12, 2023
sabine added a commit that referenced this pull request Oct 12, 2023
sabine added a commit that referenced this pull request Oct 16, 2023
@christinerose christinerose self-requested a review October 17, 2023 06:43
@cuihtlauac cuihtlauac merged commit 13d2dde into main Nov 10, 2023
3 checks passed
@cuihtlauac cuihtlauac deleted the doc-env branch November 10, 2023 10:32
cuihtlauac pushed a commit that referenced this pull request Nov 10, 2023
cuihtlauac added a commit that referenced this pull request Nov 15, 2023
This is the first tutorial after “Get Started”

This tutorial introduces basic data types in OCaml. Its goal is to teach skills on how to handle data from predefined, variant, and record types. It also includes the important concept of pattern matching on those types.

Outline:

1. Predefined Types
    1.1. Integers, Floats, Booleans, and Characters
    1.2. Strings & Byte Sequences
    1.3. Arrays & Lists
    1.4. Options & Results
    1.5. Tuples
    1.6. Functions
    1.7. Unit
2. User-Defined Types
    2.1. Variants
    2.2. Polymorphic Data Types
    2.3. Records
    2.4. Type Aliases
3.  A Complete Example: Mathematical Expressions


---------

Co-authored-by: Cuihtlauac ALVARADO <cuihtmlauac@tarides.com>
Co-authored-by: Christine Rose <christinerose@users.noreply.github.com>
Co-authored-by: sabine <sabine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Functions and Values
4 participants