blob: bbed216b94b75e4754d5ef2f5304a0ef6d05cdef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package todolist
func AddIfNotThere(arr []string, items []string) []string {
for _, item := range items {
there := false
for _, arrItem := range arr {
if item == arrItem {
there = true
}
}
if !there {
arr = append(arr, item)
}
}
return arr
}
func AddTodoIfNotThere(arr []*Todo, item *Todo) []*Todo {
there := false
for _, arrItem := range arr {
if item.Id == arrItem.Id {
there = true
}
}
if !there {
arr = append(arr, item)
}
return arr
}
|