Pat Gunn (dachte) wrote,
Pat Gunn
dachte

Orbiting Symbols

Just did some code changes to my netdiary software. Substantial code cleanups, and they're beautiful too. Here's the relevant part of the old code:

my @files = readdir(SUMDIR); # read all the filesclosedir(SUMDIR);

my @filelist = sort {$b <=> $a} @files; # Numerically sort themfit: for($idx=0; $idx <= $#filelist; $idx++)
{
if($filelistLINK =~ /summary/i){next fit;} # skip index
if($filelistLINK =~ /\./) {next fit;} # Skip '.' and '..'
parsefile($filelistLINK); # Actually parse a file
}
And the new code:

my @files = # List of files is
sort {$b <=> $a} # a numerically sorted list
grep !/^\./, # Skipping . and ..
grep !/^summary/, # and skipping the summary file
readdir(SUMDIR); # from all the files
closedir(SUMDIR);

for($idx=0; $idx <= $#files; $idx++)
{
parsefile($filelistLINK);
}

For some odd reason, the way those function calls nest creates a strange image in my mind, like an ordinary program would be like


-------------------------------

But that part is more like
^
---------------/ \---

And I can imagine rewriting it to pull that loop even higher, as fewer portions between statements exist and things nest further. For some reason, I'm getting thoughts that perhaps with sufficient thought, the entire program could be written going up rather than going across, although that might look ugly (both in metaphor and in the actual code). Maybe that's what LISP and similar languages would normally look like.

Tags: programming
Subscribe

  • Revising Dreams

    Dream:I was in some strange kind of situation where I had just managed to escape some kind of captors in a large school, but didn't feel safe to…

  • Visiting a Dream Element

    Just had an extended conversation in a dream.. I may have written about this before here. If so, this is an elaboration. One of the things that was…

  • Half-written dreams

    Last night I had a strange dream that was operating from the certainty that I was going to have a baby (not physically), but didn't actually provide…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments