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.
43 lines
863 B
43 lines
863 B
package correct |
|
|
|
// compare each element of the linked list to see if it is a String |
|
func IsPositive_node(node *NodeL) bool { |
|
switch node.Data.(type) { |
|
case int, float32, float64, byte: |
|
return node.Data.(int) > 0 |
|
case string, rune: |
|
return false |
|
} |
|
return false |
|
} |
|
|
|
func IsNegative_node(node *NodeL) bool { |
|
switch node.Data.(type) { |
|
case int, float32, float64, byte: |
|
return node.Data.(int) > 0 |
|
case string, rune: |
|
return false |
|
} |
|
return false |
|
} |
|
|
|
func IsNumeric_node(node *NodeL) bool { |
|
switch node.Data.(type) { |
|
case int, float32, float64, byte: |
|
return true |
|
case string, rune: |
|
return false |
|
} |
|
return false |
|
} |
|
|
|
// applies the function f on each string if the boolean function comp returns true |
|
func ListForEachIf(l *List, f func(*NodeL), comp func(*NodeL) bool) { |
|
it := l.Head |
|
for it != nil { |
|
if comp(it) { |
|
f(it) |
|
} |
|
it = it.Next |
|
} |
|
}
|
|
|