* "traveral" here is from Lazy Depth First Traversal
* "lazily take each" here is from Iterators
To lazily group the connected components given a collection of nodes:
First, mark all nodes unseen.
Then, with a traversal that can stop early when unmarkable
lazily take each node from unseen,
grouping the traversal of that node into a component
and yielding that component
mark is a concept used in grouping connected components.
to mark a collection as unseen means to copy it into unseen.
to mark as seen successfully given a value, remove the value from unseen.
to mark as seen will fail if the node is not in unseen
unmarkable means a given node cannot be marked as seen
marked means mark
"collect into" means to append to the list of connected components
"all nodes" means the collection of nodes
###
Lazy Depth First Traversal is a concept.
To do lazy depth first traversal given a node:
yield this node,
then, yield the results from traversal for each of this node's bonds
If depth first traversal can stop early:
when it should stop early given the node, there is no result
otherwise the result is traversing the node
traversal means depth first traversal
traversing means traversal
###
Iterators is a concept
To lazily take each from a collection:
while the collection is not empty,
remove an item from the collection,
and yield that item
Last active
October 15, 2020 00:25
-
-
Save micimize/f996d34e16f517ce27cdeee8b5036a52 to your computer and use it in GitHub Desktop.
idea for how programming could be written in almost english
But the fundamental idea is to find some of the concepts we use implicitly in natural language and build a language that:
- can leverage those concepts to better bridge the gap between our thoughts and code
- can be fluently spoken, read, and heard
this has been done: https://osmosianplainenglishprogramming.blog/
but why isn't it done more? To do it really well you'd want:
- NLP-based stemming and some other grammatical niceties
- bi-directional mapping to another language, like python.
So instead of creating a custom language, you piggyback on another. The obvious gain is accessibility.
def read_parts(name: str, number_of_parts = 1):
for part in range(0,number_of_parts):
part_filename = f'{name}_{part}.txt'
with open(part_filename) as file:
yield file.read()
yield "END"
could be something like:
# ! indicates emphasis escaping the variable
read parts takes a name string and number of parts defaulting to one.
for each part in the range of zero and number of parts,
the part filename is the formatted string of name! underscore part! dot T X T.
Then, with the open part filename as file,
yield the result of file dot read
pop two contexts, then yield the string capital E capital N capital D
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Function definitions:
Macro definitions:
Obviously this is all pseudocode and idk if some of the constructs make sense, like the boolean DSL in
to mark as seen
: