Skip to content

Commit

Permalink
slices exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
nithin001 committed Jul 22, 2016
1 parent 75892f7 commit 0f90e23
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions data_structures/slices.go
Expand Up @@ -4,22 +4,48 @@ type mapOperation func(int32) int32
type filterOperation func(int32) bool

func mapInts(op mapOperation, vals []int32) []int32 {
return []int32{}
var result []int32
for _,elem := range vals{
result = append(result,op(elem))
}
return result

}

func filterInts(op filterOperation, vals []int32) []int32 {
return []int32{3}
var result []int32
for _,elem := range vals{
if op(elem){
result = append(result,elem)
}
}
return result
}

func concatenate(dest []string, newValues ...string) []string {
return nil
for _,elem := range newValues{
dest = append(dest,elem)
}
return dest
}

func equals(list1 []string, list2 []string) bool {
return false
if len(list1)!=len(list2){
return false
}else{
for index,_:=range list1{
if list1[index]!=list2[index]{
return false
}
}
return true
}
}

func partialReverse(src []int, from, to int) []int {
return nil
var result []int
for i := to; i < from; i-- {
result = append(result,src[i])
}
return result
}

0 comments on commit 0f90e23

Please sign in to comment.