ComputerScientist
174 subscribers
14 photos
3 files
206 links
▜ The Inventor

Stuff that inspire you to create.

See also: ▙ @LitMind
Download Telegram
The abstract versus the implementation
Do ends justify the means? "ends" ≡ the abstract, "means" ≡ the implementation

Factors to consider when implemeting an idea:
correctness
• time complexity
• memory complexity
• one-to-one correspondece
#data_structure
Bloom map
A Bloom filter is a space-efficient probabilistic data structure, that is used to test whether an element is a member of a set.
• False positive matches are possible, but false negatives are not – in other words, a query returns either "possibly in set" or "definitely not in set"
• Elements can be added to the set, but not removed
• The more elements that are added to the set, the larger the probability of false positives.
• Despite having a fixed size, adding an element never fails
• Union (lossless i.e. equal to one made from scratch) and intersection (lossy) of two with the same size and set of hash functions can be implemented with bitwise OR and AND operations respectively.
#data_structure
Graph
Methods used to represent a finite graph:

Adjacency list: a set of records; where each record stores the neighbors of a vertex. This allows the storage of additional data on the vertices. Additional data can be stored if edges are also stored as records, in which case each vertex stores its incident edges and each edge stores its incident vertices.

Adjacency matrix: a square matrix; where the rows and columns respectively represent source and destination vertices. The elements of the matrix indicate whether pairs of vertices are adjacent or not in the graph.
• If the graph is simple, the adjacency matrix is a (0,1)-matrix with zeros on its diagonal.
• If the graph is undirected, the adjacency matrix is symmetric
Data on edges and vertices must be stored externally. Only the cost for one edge can be stored between each pair of vertices.

Incidence matrix: A two-dimensional Boolean matrix, in which the rows and columns respectively represent the vertices and the edges. The entries indicate whether the vertex at a row is incident, i.e. related, to the edge at a column.
Idea: distributed programming
“Let it first blossom, then bear fruit, then ripen.”
— Epictetus
Quantifier operators
• All: checks if all the elements satisfy a condition
• Any: checks if any of the elements satisfy a condition
• Contains: checks if it contains a specific element

#CSharp, LINQ
#toRead

📚 A case against syntax highlighting
by Linus Åkesson

http://www.linusakesson.net/programming/syntaxhighlighting/
“Syntax highlighting is juvenile. When I was a child, I was taught arithmetic using colored rods. I grew up and today I use monochromatic numerals.”
— Rob Pike
Regular expression based syntax highlighting is often wrong
“No syntax highlighting isn’t really what I wanted, I wanted nearly none. Still like string backgrounds to be tweaked and comments to be faded.”
― Robert Melton
List := ordered collection of homogeneous items
#regex
Regex Cheatsheet
All the rules apply to all of the three languages: #Python, #Perl (PCRE) and #JavaScript, unless stated otherwise.
Source: debuggex.com

Basics
.: Any character except newline
a: The character a
ab: The string ab
a|b: a or b
a*: 0 or more a's
\: Escapes a special character

Quantifiers
*: 0 or more
+: 1 or more
?: 0 or 1
{2}: Exactly 2
{2, 5}: Between 2 and 5
{2,}: 2 or more
(,5}: Up to 5 (Python only)
⚠️ Default is greedy. Append ? for reluctant.

Groups
(...): Capturing group
(?:...): Non-capturing group
\Y: Match the Y'th captured group
Python and PCRE:
(?P<Y>...): Capturing group named Y
(?P=Y): Match the named group Y
(?#...): Comment
PCRE only:
(?>...): Atomic group
(?|...): Duplicate group numbers
(?R): Recurse into entire pattern
(?Y): Recurse into numbered group Y
(?&Y): Recurse into named group Y
\g{Y}: Match the named or numbered group Y
\g<Y>: Recurse into named or numbered group Y

Character Classes
[ab-d]: One character of: a, b, c, d
[^ab-d]: One character except: a, b, c, d
[\b]: Backspace character
\d: One digit
\D: One non-digit
\s: One whitespace
\S: One non-whitespace
\w: One word character
\W: One non-word character

Assertions
^: Start of string
$: End of string
\b: Word boundary
\B: Non-word boundary
(?=...): Positive lookahead
(?!...): Negative lookahead
Python and PCRE:
\A: Start of string, ignores m flag
\Z: End of string, ignores m flag
(?<=...): Positive lookbehind
(?<!...): Negative lookbehind
(?()|): Conditional
PCRE:
\G: Start of match

Flags
i: Ignore case
m: ^ and $ match start and end of line
Python and PCRE:
s: . matches newline as well
x: Allow spaces and comments
L: Locale character classes
u: Unicode character classes
(?iLmsux): Set flags within regex
JavaScript only:
g: Global Match

Special Characters
\n: Newline
\r: Carriage return
\t: Tab
\YYY: Octal character YYY
\xYY: Hexadecimal character YY
JavaScript and PCRE:
\0: Null character
\cY: Control character Y
Hexadecimal character YY (\uYY for JavaScript and \x{YY} for PCRE)

Replacement
Python only:
\g<0>: Insert entire match
\g<Y>: Insert match Y (name or number)
\Y: Insert group numbered Y
JavaScript only:
$$: Inserts $
$&: Insert entire match
$`: Insert preceding string
$': Insert following string
$Y: Insert Y'th captured group

Escapes
PCRE only:
\Q..\E: Remove special meaning

POSIX Classes
PCRE only:
[:alnum:]: Letters and digits
[:alpha:]: Letters
[:ascii:]: Ascii codes 0 - 127
[:blank:]: Space or tab only
[:cntrl:]: Control characters
[:digit:]: Decimal digits
[:graph:]: Visible characters, except space
[:lower:]: Lowercase letters
[:print:]: Visible characters
[:punct:]: Visible punctuation characters
[:space:]: Whitespace
[:upper:]: Uppercase letters
[:word:]: Word characters
[:xdigit:]: Hexadecimal digits
#toRead

📚 Writing a TextMate Grammar
by Matt Neuburg

https://www.apeth.com/nonblog/stories/textmatebundle.html
Idea: "wizard" as an app template
Why returns a causal link.
How returns a causal tree, which is comprised of causal links.
There is no creation, only allocation.
Nile, the language of formalization of ideas
steepness of TreeView
Operator precedence leads to quasi-balanced parse tree.
#AI
AI-completeness
The most difficult problems are informally known as AI-complete or AI-hard, by analogy with NP-complete and NP-hard in complexity theory, implying that the difficulty of these computational problems is equivalent to that of solving the central artificial intelligence problem—making computers as intelligent as people, or strong AI. Since many AI problems have no formalisation yet, conventional complexity theory does not allow the definition of AI-completeness. To call a problem AI-complete reflects an attitude that it would not be solved by a simple specific algorithm. They include:
• Computer vision (and subproblems such as object recognition)
• Natural language understanding (and subproblems such as text mining, machine translation, and word sense disambiguation)
• Dealing with unexpected circumstances while solving any real world problem, whether it's navigation or planning or even the kind of reasoning done by expert systems.
• Peer Review
Bongard problems
• Automatic speech recognition