src/LinkedLists.jl

changeset 3
ec9084e97e46
parent 0
888dfd34d24a
child 4
59fd17a3cea0
equal deleted inserted replaced
2:fc7430da1d7a 3:ec9084e97e46
1 #################################################################### 1 ####################################################################
2 # Immutable linked list (different from the mutable lists of 2 # Immutable linked lists (different from the mutable lists of
3 # https://github.com/ChrisRackauckas/LinkedLists.jl) 3 # https://github.com/ChrisRackauckas/LinkedLists.jl)
4 #################################################################### 4 ####################################################################
5 5
6 module LinkedLists 6 module LinkedLists
7
8 using DelimitedFiles
9
10 using ..StructTools
7 11
8 ############## 12 ##############
9 # Our exports 13 # Our exports
10 ############## 14 ##############
11 15
12 export LinkedListEntry, 16 export LinkedListEntry,
13 LinkedList, 17 LinkedList,
14 unfold_linked_list 18 unfold_linked_list,
19 write_log
15 20
16 ############# 21 #############
17 # Data types 22 # Data types
18 ############# 23 #############
19 24
47 push!(res, value) 52 push!(res, value)
48 end 53 end
49 return reverse(res) 54 return reverse(res)
50 end 55 end
51 56
57 # Write out a a “log” of LinkedList of IterableStructs as a delimited file
58 function write_log(filename::String, log::LinkedList{T}, comment::String) where T <: IterableStruct
59 open(filename, "w") do io
60 print(io, comment)
61 writedlm(io, [String.(fieldnames(T))])
62 writedlm(io, unfold_linked_list(log))
63 end
52 end 64 end
65
66 end

mercurial