3 ms·
Or one liners: import sys; open(sys.argv[2], 'w').writelines(sorted(open(sys.argv[2], 'w').writelines()) (use-package :com.informatimago.common-lisp.cesarum.f
by informatimago 13y ago
Or one liners:
import sys; open(sys.argv[2], 'w').writelines(sorted(open(sys.argv[2], 'w').writelines())
(use-package :com.informatimago.common-lisp.cesarum.file) (setf (string-list-text-file-contents outpath) (sort (string-list-text-file-contents inpath) (function string<)))
Indeed, what kills languages like C or C++11 in the scripting domain, is the need for declarations and other kind of boiler plate. That said, with C++11 there are means to write a library requiring less declarations, but it's still a cultural problem (beside the hard work that it would require).
- aidos 13y agoYour first example is erroneous - perhaps a good example of why you shouldn't try to squeeze everything into a single line of code :) import sys src = open(sys.argv[1]) dest = open(sys.argv[2], 'w') dest.writelines(sorted(src))