Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

post bits of code you like

Name: Anonymous 2005-08-02 1:52

i shall start:

open(F,"find -type f|");
while (<F>) {
 $_ = substr($_,2,-1);
 print "$_\n" if $v;
 push @{$dups{substr(`md5sum -b "$_"`,0,31)}}, $_;
}
close(F);

for every file in a directory it checksums the file, then adds the checksum as a key to a hash, the value being an array reference. the filename is then added to the array.

so basically the arrays have a list of files with the same checksum. i use this to find duplicates files.

Name: Anonymous 2005-11-18 12:28

I'm no lisper, but here's my take.

We're defining a function called fib, which takes an argument n.

The body of fib is made up of the application of an anonymous function, which takes two arguments, a function f and a number n. This anonymous function applies the function f it was passed to f and n.

The last argument to the anonymous function is n, the same n that fib was passed. The first argument is another anonymous function, which it too takes two arguments, a function f and a number n. If n < 2 then it returns 1, otherwise it applies the function f it was passed to f and n-1, and adds that to the application of f and n-2.

One wonders if this doesn't have exponential time complexity. One also questions the sanity of lispers.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List