src/LinkedLists.jl

changeset 3
ec9084e97e46
parent 0
888dfd34d24a
child 4
59fd17a3cea0
--- a/src/LinkedLists.jl	Mon Nov 18 11:30:30 2019 -0500
+++ b/src/LinkedLists.jl	Mon Nov 18 11:31:40 2019 -0500
@@ -1,17 +1,22 @@
 ####################################################################
-# Immutable linked list (different from the mutable lists of
+# Immutable linked lists (different from the mutable lists of
 # https://github.com/ChrisRackauckas/LinkedLists.jl)
 ####################################################################
 
 module LinkedLists
 
+using DelimitedFiles
+
+using ..StructTools
+
 ##############
 # Our exports
 ##############
 
 export LinkedListEntry,
        LinkedList,
-       unfold_linked_list
+       unfold_linked_list,
+       write_log
 
 #############
 # Data types
@@ -49,4 +54,13 @@
     return reverse(res)
 end
 
+# Write out a a “log” of LinkedList of IterableStructs as a delimited file
+function write_log(filename::String, log::LinkedList{T}, comment::String) where T <: IterableStruct
+    open(filename, "w") do io
+        print(io, comment)
+        writedlm(io, [String.(fieldnames(T))])
+        writedlm(io, unfold_linked_list(log))
+    end
 end
+
+end

mercurial