Skip to content

Commit f40c449

Browse files
TimeTravelPenguinquachpas
authored andcommitted
refactor: update Return to handle array input
Update the `Return ` definition to handle cases where the value is an array, joining elements with a comma. Also, expanded and updated tests to expand coverage of additional edge cases.
1 parent 791ce31 commit f40c449

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

algorithmic.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,6 @@
205205

206206
// Instructions
207207
#let Assign(var, val) = (var + " " + $<-$ + " " + arraify(val).join(", "),)
208-
#let Return(arg) = (strong("return") + " " + arg,)
208+
#let Return(arg) = (strong("return") + " " + arraify(arg).join(", "),)
209209
#let Terminate = (smallcaps("terminate"),)
210210
#let Break = (smallcaps("break"),)

tests/return/ref/1.png

7.35 KB
Loading

tests/return/test.typ

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,12 @@
33
#set page(margin: .1cm, width: 4cm, height: auto)
44
#algorithm({
55
import algorithmic: *
6+
7+
let Foo = Fn.with("foo")
8+
let Bar = Call.with("bar")
9+
610
Return[$x$]
11+
Return($x$)
12+
Return(Foo[$x$])
13+
Return(Bar[$x$])
714
})

0 commit comments

Comments
 (0)