diff --git a/README.md b/README.md index c23ad87..8aa7dfc 100644 --- a/README.md +++ b/README.md @@ -266,6 +266,18 @@ IfElseChain( // Alternating content and bits image of an ifelsechain statement with condition x < y and conditional statement assign y to x, then condition x + +IfElseInline +IfElseInline(condition: content, true-case: content, false-case: content) + + +```typst +Assign($m$, IfElseInline($x < y$, $x$, $y$)) +``` + + +image of an ifelseinline expression with condition x < y, true expression x, and false expression y being assigned to m + diff --git a/algorithmic.typ b/algorithmic.typ index fd42ba7..76f92bb 100644 --- a/algorithmic.typ +++ b/algorithmic.typ @@ -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(", "),) diff --git a/tests/ifelseinline/.gitignore b/tests/ifelseinline/.gitignore new file mode 100644 index 0000000..40223be --- /dev/null +++ b/tests/ifelseinline/.gitignore @@ -0,0 +1,4 @@ +# generated by tytanic, do not edit + +diff/** +out/** diff --git a/tests/ifelseinline/ref/1.png b/tests/ifelseinline/ref/1.png new file mode 100644 index 0000000..eafa43b Binary files /dev/null and b/tests/ifelseinline/ref/1.png differ diff --git a/tests/ifelseinline/test.typ b/tests/ifelseinline/test.typ new file mode 100644 index 0000000..1de13bf --- /dev/null +++ b/tests/ifelseinline/test.typ @@ -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$)) +})