xah talk show 2022-08-08 programing language design, walk directory, in python, golang, PowerShell, emacs lisp, WolframLang
ease and intuitiveness ranking: PowerShell, WolframLang, emacs lisp, python, golang. demo it.
both python and golang had to change their walk dir function to improve speed.
emacs lisp and WolframLang, are very different from the industrial langs such as python golang. math langs focus on function aspects, input, output. Static. e.g. sin(x). The non-math langs adds a time concept. This is also the different between math and algorithm. What is, vs how to.
import os
import re
input_path = "c:/Users/xah/web/xahlee_info/emacs/"for dir_path, subdir_list, file_list in os.walk(input_path):
for fname in file_list:
if (re.search(r"\.ts$|\.js$", fname, re.U)):
print(dir_path + fname)
packagemainimport (
"fmt""io/fs""path/filepath""regexp"
)
varxDir = "c:/Users/xah/web/xahlee_info/emacs/"funcmain() {
var doF = func(xpathstring, xinfo fs.DirEntry, xerrerror) error {
// first thing to do, check error. and decide what to do about it
ifxerr != nil {
fmt.Printf("error [%v] at a path [%q]\n", xerr, xpath)
returnxerr
}
varx, err = regexp.MatchString(`\.ts$|\.js$`, xpath)
if err != nil {
panic(err)
}
ifx {
fmt.Printf("%v\n", xpath)
}
returnnil
}
err := filepath.WalkDir(xDir, doF)
if err != nil {
fmt.Printf("error walking the path %q: %v\n", xDir, err)
}
}