arrays - syntax error: unexpected name, expecting ) -


i have code bst in go. keep getting error message. using noted pad , beginner. error in loop. under insertlist func.

type node struct{     left *node     right *node     val int     }   func insert(tree *node, element int) *node{     if tree == nil{         tree = &node{nil, nil, element}         } else if element > tree.val{         tree.right = insert( tree.right, element)         } else if element < tree.val{         tree.left = insert( tree.left, element)         }     return tree     } func insertlist(elementlist []int) *node{     if tree == nil{         i:=0; i<[]int.len; i++{              tree = insert([i]int)}         return tree}}  func displaybst(tree *node){     if ( tree != nil) {         displaybst( tree.left)         fmt.println(tree.val)         displaybst(tree.right)}}   func main(){       l := [10]int{100, 3, 3, 200, 5, 8, 5, 200, 0, -4}       s := l[:]       insertlist(s)       displaybst(insertlist(s))       fmt.println()} 

this should past syntax errors:

package main  import "fmt"  type node struct {     left  *node     right *node     val   int }  func insert(tree *node, element int) *node {     if tree == nil {         tree = &node{nil, nil, element}     } else if element > tree.val {         tree.right = insert(tree.right, element)     } else if element < tree.val {         tree.left = insert(tree.left, element)     }     return tree }  func insertlist(tree *node, elementlist []int) *node {     if tree == nil {         := 0; < len(elementlist); i++ {             tree = insert(tree, elementlist[i])         }     }     return tree }  func displaybst(tree *node) {     if tree != nil {         displaybst(tree.left)         fmt.println(tree.val)         displaybst(tree.right)     } }  func main() {      l := [10]int{100, 3, 3, 200, 5, 8, 5, 200, 0, -4}      s := l[:]      var t *node      insertlist(t, s)      displaybst(insertlist(t, s))      fmt.println() } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -