-
-
Notifications
You must be signed in to change notification settings - Fork 220
None
Giorgio Garofalo edited this page Jan 23, 2025
·
10 revisions
None is a particular value, which represents nothing or emptiness (similarly to null in many programming languages).
Functions can return it, and it's also used as a placeholder for optional parameters.
| Function | Description | Return type |
|---|---|---|
.none |
Creates an empty value. | none |
.isnone {value} |
Checks whether value is none. |
Boolean |
.otherwise {value} {fallback} |
Returns value if it is not none, fallback otherwise.Works best with function call chaining. |
Type of either value or fallback
|
.ifpresent {value} {lambda} |
If value is not none, maps it to a new value according to the lambda. If none, returns none.Works best with function call chaining. |
Type returned by lambda, or none
|
.takeif {value} {lambda} |
Returns value if the boolean-returning lambda is accepted on value. Returns none otherwise.Works best with function call chaining. |
Type of value, or none
|
Hi! I'm .name::otherwise {unnamed}
If
nameisJohn: Hi! I'm John
If it isnone: Hi! I'm unnamed
.num::takeif {@lambda x: .x::equals {5}}
If
numis 5: 5
Otherwise: None
Confused about
@lambda? It begins a parametric inlineLambda. Check its page for further details.
.num::takeif {@lambda x: .x::iseven}::ifpresent {Even}::otherwise {Odd}
If
numis even: Even
Otherwise: Odd
.x::ifpresent {@lambda Yes, .1 is present}::otherwise {Not present}
If
xissomething: Yes, something is present
If it isnone: Not present
Here, the lambda parameter is implicit and accessed by position.
- Figures
- Image size
- TeX formulae
- Table caption
- Code caption
- Decorative headings
- Alerts (quote types)
- Quotation source
- Cross-references
- Page breaks
- Text symbols (text replacement)
- Emojis
- Document metadata
- Theme
- CSS
- Fonts
- Page format
- Page margin content
- Page counter
- Persistent headings
- Automatic page break
- Numbering
- Paragraph style
- Caption position
- Table of contents
- Bibliography
- Footnotes
- Stacks (row, column, grid)
- Container
- Align
- Float
- Figure
- Clip
- Box
- Collapsible
- Landscape
- Whitespace
- Variables
- Optionality
- Math
- Conditional statements
- Loops
- Let
- Destructuring
- String manipulation
- Table manipulation: sorting, computing, and more
- Table generation
- String
- Number
- Markdown content
- Boolean
- None
- Enumeration entry
- Iterable
- Dictionary
- Range
- Lambda
- Size(s)
- Color
- Dynamic
- Paper: abstract, definitions, theorems, and more