repl.it
@psikosen/

GreenyellowLargePayware

Elixir

No description

fork
loading
Files
  • main.exs
  • Test.txt
main.exs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import List

list = [:text,:flex, :blex]

defmodule TreeNode do
  defstruct  data: '', parent: '' ,children: []

 def create(d,p,c) do
      tree = %TreeNode{} 
 	  tree = %{ %TreeNode{}| data: d}
	  tree = %{ %TreeNode{}| parent: p}
	  tree = %{ %TreeNode{}| children: c}
 end

 def add_to(tree,d) do
    arr = tree.children
	tr = %{tree | children: arr ++ d}
 end

 def remove_from(tree,pos) do
	IO.inspect('==========')   
	t =  tree.children
	t =  List.delete(t,2)
 end

 def searchList(items) do
   Enum.each items, fn(item) ->
      IO.inspect(item)
   end
 end
 
 def locate(items) do
  prep =  Enum.at(items,2)

 end

end

tt= TreeNode.create("Test Data","parent",[1,2,3,4])
t1 = TreeNode.add_to(tt,[6])
t2 = TreeNode.remove_from(t1,1)
t3 = TreeNode.searchList(t2)
t4 = TreeNode.locate(t2)
IO.inspect t4
Fetching token
?