From 74c6a2e19560ef789dd9b6b493d64c5f75f52780 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Mon, 28 Oct 2024 17:39:14 -0400 Subject: [PATCH] Added more functions to stateContents type, removed append because I don't think I need it --- stateContents.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/stateContents.go b/stateContents.go index b9690ec..1bc5043 100644 --- a/stateContents.go +++ b/stateContents.go @@ -4,8 +4,19 @@ import "slices" type stateContents []int // Represents the contents of the current state - character classes can have multiple contents, which is why it is represented as a slice -func newContents() stateContents { +func newContents(data ...int) stateContents { toReturn := stateContents{} + for _, i := range data { + toReturn = append(toReturn, i) + } + return toReturn +} + +func rune2Contents(data []rune) stateContents { // Convert a rune slice into a stateContents type, then return it. The runes are simply cast to ints. + toReturn := newContents() + for _, r := range data { + toReturn = append(toReturn, int(r)) + } return toReturn } @@ -13,9 +24,3 @@ func newContents() stateContents { func (c stateContents) contains(val int) bool { return slices.Contains(c, val) } - -// Appends val to c -func (c *stateContents) append(val int) { - *c = append(*c, val) - return -}