diff options
author | shusa <shusa> | 2005-11-10 23:37:34 +0000 |
---|---|---|
committer | shusa <shusa> | 2005-11-10 23:37:34 +0000 |
commit | d7888aa3ecaf33f8e949313653e868f4ae89518a (patch) | |
tree | 9b3eac09648c596cf42d494f198f742ecf2c8b4f /Tools/CodeGen/CodeGen.m | |
parent | aa73db4fd139fe7ad331e770733989b63263cf17 (diff) |
add AddToFile function, required in the bamification process
Diffstat (limited to 'Tools/CodeGen/CodeGen.m')
-rw-r--r-- | Tools/CodeGen/CodeGen.m | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Tools/CodeGen/CodeGen.m b/Tools/CodeGen/CodeGen.m index 63e9988..ddb359e 100644 --- a/Tools/CodeGen/CodeGen.m +++ b/Tools/CodeGen/CodeGen.m @@ -38,6 +38,8 @@ SeparatedBlock::usage = "SeparatedBlock[block] returns a version of 'block' with "a newline before it."; GenerateFile::usage = "GenerateFile[name, block] writes 'block' to a file of the " <> "specified 'name'."; +AddToFile::usage = "AddToFile[name, block] appends 'block' to a file of the " <> + "specified 'name'."; IncludeFile::usage = "IncludeFile[name] returns a block of code" <> "that includes a header file (i.e '#include \"name\"')."; DeclareVariable::usage = "DeclareVariable[name, type] returns a block of code " <> @@ -135,6 +137,11 @@ GenerateFile[filename_, contents_] := WriteString[fp, FlattenBlock[contents]]; Close[fp]]; +AddToFile[filename_, contents_] := + Module[{fp = OpenAppend[filename]}, + WriteString[fp, FlattenBlock[contents]]; + Close[fp]]; + intersperse[l_, x_] := If[l == {}, {}, |