mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
519 B
28 lines
519 B
package solutions |
|
|
|
// applies a function in argument to each element of the linked list |
|
func ListForEach(l *List, f func(*NodeL)) { |
|
it := l.Head |
|
for it != nil { |
|
f(it) |
|
it = it.Next |
|
} |
|
} |
|
|
|
func Add2_node(node *NodeL) { |
|
switch node.Data.(type) { |
|
case int: |
|
node.Data = node.Data.(int) + 2 |
|
case string: |
|
node.Data = node.Data.(string) + "2" |
|
} |
|
} |
|
|
|
func Subtract3_node(node *NodeL) { |
|
switch node.Data.(type) { |
|
case int: |
|
node.Data = node.Data.(int) - 3 |
|
case string: |
|
node.Data = node.Data.(string) + "-3" |
|
} |
|
}
|
|
|