xtodo python
dion's try at WolframLang's Map
def map_at_depth(func, node, depth, target_depth, get_children): if target_depth < depth: return else if target_depth == depth: yield func(node) for child in get_children(node): yield from map_at_depth(func, child, depth+1, target_depth, get_children)
WHAT DOES THIS MEANS EXACTLY? :
Empty matches for the pattern are replaced only when not adjacent to
a previous match, so "sub('x*', '-', 'abc')" returns
'-a-b-c-'
.
In addition to character escapes and backreferences as described above, \g<name>
will use the substring matched by the group named name
, as defined by the (?P<name>…)
syntax. \g<number>
uses the corresponding group number; \g<2>
is therefore equivalent to \2
, but isn't ambiguous in a replacement such as \g<2>0
. \20
would be interpreted as a reference to group 20, not a reference to group 2 followed by the literal character 0
.
The backreference \g<0>
substitutes in the entire substring matched by the pattern.
- 2022-01-12 blog this python print unicode to stdout
sys.stdout.reconfigure(encoding='utf-8')
# python 3 import sys sys.stdout.reconfigure(encoding="utf-8") print(sys.stdout.encoding) # 2022-01-11 need to get python to print unicode and shows as char, when run in emacs print("unicode • BULLET")
xx = " TypeScript Tutorial Deno: Intro By Xah Lee. Date: 2022-10-18. Deno is a great JavaScript compiler, TypeScript compiler, and runtime engine. With Deno, you can run JavaScript or TypeScript like a shell script in terminal. Deno is created by Ryan Dahl, the same guy who created node.js in 2009. but nodejs became corrupt over the years, so Ryan Dahl created created a better version called deno in 2018. Download and Install Deno Download Deno at https://deno.land/ run deno interactively Type deno to start the interactive prompt. Type Ctrl+d to exit. deno js 2022-06-13 5cv36 deno js 2022-06-13 5cv36 run deno as as shell script deno run test.js Run Deno in Emacs For emacs users, you can eval the JavaScript code in a buffer directly. See: Emacs: Run Current File 🚀 TypeScript TypeScript Install TypeScript Filename Extension TypeScript: Convert to JavaScript TypeScript: Errors TypeScript Misc Notes deno Deno: Intro Deno: Print Version Deno: Ignore Format " xlist= xx.split() print( max(set(zip(xlist,xlist[1:])), key=xlist.count) ) # you just said find the most common bigram # dict of word + count: {w: xlist.count(w) for w in set(xlist)} # sorted dict of word + count: from collections import OrderedDict OrderedDict((w,xlist.count(w)) for w in sorted(set(xlist)))
- 2022-10-14 review Python: How to Write a Module , maybe combine with Python: Import Module
- 2022-10-09 review code Python: Convert File Encoding
- 2022-09-04 Python: Regex Syntax
- 2022-07-31 Python Regex re.findall TODO: need another example here showing what is meant by “unless they touch the beginning of another match.”
- Python: Regex Functions
- 2022-01-29 perl move Delete Duplicate Image Files and maybe put code up