# HG changeset patch # User Tuomo Valkonen # Date 1574094700 18000 # Node ID ec9084e97e46335ac55bff76c0ee2ddd7850899c # Parent fc7430da1d7a7467b9f8cd3d1cb233ea313be0d2 Add write_log to LinkedLists diff -r fc7430da1d7a -r ec9084e97e46 Manifest.toml --- a/Manifest.toml Mon Nov 18 11:30:30 2019 -0500 +++ b/Manifest.toml Mon Nov 18 11:31:40 2019 -0500 @@ -1,5 +1,12 @@ # This file is machine-generated - editing it directly is not advised +[[DelimitedFiles]] +deps = ["Mmap"] +uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" + +[[Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" + [[Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" diff -r fc7430da1d7a -r ec9084e97e46 Project.toml --- a/Project.toml Mon Nov 18 11:30:30 2019 -0500 +++ b/Project.toml Mon Nov 18 11:31:40 2019 -0500 @@ -4,4 +4,5 @@ version = "0.1.0" [deps] +DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" diff -r fc7430da1d7a -r ec9084e97e46 src/AlgTools.jl --- a/src/AlgTools.jl Mon Nov 18 11:30:30 2019 -0500 +++ b/src/AlgTools.jl Mon Nov 18 11:31:40 2019 -0500 @@ -1,7 +1,7 @@ module AlgTools +include("StructTools.jl") include("LinkedLists.jl") -include("StructTools.jl") include("Iterate.jl") include("Util.jl") diff -r fc7430da1d7a -r ec9084e97e46 src/LinkedLists.jl --- 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