|
|
|
|
|
by cubano
3589 days ago
|
|
Here is the same project, done in PHP in less then 5 minutes... $split_by_whitespace = explode(file_get_contents('exaample.txt')," ");
$circular = array();
for ($i=0;$i<count($split_by_whitespace);$i++) {
array_push(array_shift($split_by_whitespace));
$circular[]=$split_by_whitespace;
}
sort($circular);
print_f($circular);
While I am sure there a lot of interesting use cases for Racket, but when it comes to processing array data, I'll take PHP everytime. |
|
2) This isn't, strictly, about processing text data but about an approach to development that Racket makes easy.
Specifically:
3) If you really want to do text processing, let's go with perl: From: http://www.perlmonks.org/?node_id=626714) Things missing from yours and the perl one:
The first three are trivially added to the other two programs (though the perl one will need some reformatting). But the fourth is impossible. Again, for this scope of project (a demonstration, mind you) the tests and static typing aren't as essential. But if you want this code to live on, and potentially become part of a library of more utilities, they're very helpful.[0] and projects that depend on this is a library call so they know the types of the arguments and returns.