Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ IfElseChain( // Alternating content and bits
</td>
<td><img src="https://raw.githubusercontent.com/typst-community/typst-algorithmic/refs/tags/v1.0.6/tests/ifelsechain/ref/1.png" alt="image of an ifelsechain statement with condition x < y and conditional statement assign y to x, then condition x" width="500"></td>
</tr>
<tr>
<td><code>IfElseInline</code></td>
<td><code>IfElseInline(condition: content, true-case: content, false-case: content)</code></td>
<td>

```typst
Assign($m$, IfElseInline($x < y$, $x$, $y$))
```

</td>
<td><img src="https://raw.githubusercontent.com/typst-community/typst-algorithmic/refs/tags/v1.0.6/tests/ifelseinline/ref/1.png" alt="image of an ifelseinline expression with condition x < y, true expression x, and false expression y being assigned to m" width="500"></td>
</tr>
</tbody>
</table>

Expand Down
3 changes: 3 additions & 0 deletions algorithmic.typ
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@
}
result
}
#let IfElseInline(condition, true-case, false-case) = (
[#true-case *if* #condition *else* #false-case],
)

// Instructions
#let Assign(var, val) = (var + " " + $<-$ + " " + arraify(val).join(", "),)
Expand Down
4 changes: 4 additions & 0 deletions tests/ifelseinline/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# generated by tytanic, do not edit

diff/**
out/**
Binary file added tests/ifelseinline/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions tests/ifelseinline/test.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#import "../../algorithmic.typ"
#import algorithmic: algorithm
#set page(margin: .1cm, width: 5cm, height: auto)
#algorithm({
import algorithmic: *
Assign($m$, IfElseInline($x < y$, $x$, $y$))
})
Loading