Skip to content

Commit

Permalink
Add two more example programs
Browse files Browse the repository at this point in the history
  • Loading branch information
healeycodes committed Jul 14, 2021
1 parent 668637d commit f4ab165
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions example programs/join.golf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
text = ["H", "i", "!", 1, 2, 3]
join = (l, char) => {
joined = ""
for i = 0; i < len(l); i = i + 1 {
joined = if i == len(l) - 1 {
joined + str(l[i])
} else {
joined + str(l[i]) + char
}
}
joined
}

assert(join(text, " ")[6], "1")
10 changes: 10 additions & 0 deletions example programs/split.golf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name = "Alice"
split = s => {
list = []
for char in s {
list.append(char)
}
list
}

assert(split(name)[0], "A")

0 comments on commit f4ab165

Please sign in to comment.