163 karma · joined Jul 27, 2014 (12y ago) · 121 submissions
comment 5y ago · link · parent
echo "foo bar" | tr ' ' '\n' | while read -r var; do echo ${var}; done
For examples in general, I guess something like "cat file.csv" could work. (the difference between using IFS= and not using it is essentially whether we want to preserve leading and trailing whitespaces or not. If we want to preserve, then we should use IFS=).comment 5y ago · link · parent
cat input.file | ... | while read -r unit; do <cmd> ${unit}; done | ...
between 'while read -r unit' and 'while IFS= read -r unit' I can probably handle 90% of the cases. (maybe I should always use IFS since I tend to forget the proper way to use it).comment 5y ago · link · parent
# cat data.csv | process-1 | process-2 | ... | process-n > final-output
Imagine you have this pipeline that already works for data.csv. But now you have data2.csv which has some difference (e.g., some values are null, while the original data.csv had no null values).
Monads are an approach to making the existing pipeline work (with minimal changes) while still being able to handle both data.csv and data2.csv. The minimal changes follow a strict rule as follows (this is not a valid shell command anymore):
# wrap(cat data.csv) ] process-1 ] process-2 ] ... ] process-n > final-output
In other words, only two kinds of changes are allowed:
- You can bring in a wrap function, that modifies the entries of the given csv data.
- You can bring in a new kind of pipe ']' instead of '|'
The idea being, the wrap function takes in original data stream, and for each "unit" (a line in the csv file, called a value) produces a new kind of data-unit (called monadic-value). Then your new pipe ']' has some additional functionality that is aware of the new kind of data-unit and is able to, e.g., process the null values, while leaving the non-null values unchanged.
Note, you didn't have to modify any of the process-1 through process-n commands.
BTW, the null value handling monad is called the 'maybe monad' (and of course there are other kinds of monads).
If you make the existing pipeline work in this way, you essentially created a monad to solve your problem (monad here is the new mechanism consisting of the new value, and the two new changes, the wrap function, and the new pipe).
edit: There may be a need to also modify the '>' mechanism. But I think that is not essential to the idea of a monad, since you could replace ">" with "] process-n+1 >" (i.e., you created a new outermost function 'process-n+1' that simply converts the monadic-values back to regular values).
edit 2: If instead of handling null-values, the purpose is to "create side-effects" e.g., at every pipe invocation, dump all/some contents of the data into a log file, then the kind of monad you end up creating would be something like an "I/O monad".
comment 5y ago · link · parent
- BOINC looks like an interface for end-users to volunteer compute resources for various (existing) distributed-computing projects.
- Post is about building your own distributed system starting from minimal-yet-effective principles.
comment 5y ago · link · parent
It's a BSD/MIT-license tool. Any idea why they did that?
second big-picture question: how hard is it to code up ast (as long as the source language is not C++)? we have lexers, parsers, PEGs, what not.
comment 5y ago · link · parent
The trailing zero was part of the measurement and, hence, is included in the significant digit count.
That also means you can't just measure 1.7320, and report 1.73200 instead (or 1.732). You have to report only, and exactly, what you measured.
(I'm ignoring rounding in what I said).
comment 5y ago · link · parent
I've been called every name in the book by my own friends, e.g., Dunning-Kruger, "full of it", etc, etc. I know all these terms. I just don't know how to come across as a humble person, despite it hurting in my personal/social/work life. The only thing that helps is if I interact with others less (there I go again).
comment 5y ago · link · parent
comment 5y ago · link · parent
I guess I'll have to think about dynamic-scoping a little more.
comment 5y ago · link · parent
- I don't get big schemes (like R6RS). For a while, I thought of my own implementation of R5RS. But I've heard R7RS is pretty much R5RS with improvements. So R7RS it is.
- But I'd like to have macros. I wonder if R7RS has macros.
- Mainly interested in crazy metaprogramming and logic/relational experiments using Friedman/Byrd school of thought (reasoned schemer, minikanren, constraint kanren, that sort of stuff).
- Finally instead of rolling my own from scratch, I've heard I could use something like chibi as a starting point (additional points since chibi is implemented in C).
Comments?
comment 5y ago · link · parent
My guess: they're going to gloat over immediate-mode for a decade or two, then some folks are going to develop retained-mode code (library/framework/whatever) on top of imgui, and then they're going to gloat over that for another decade. And they'd reach a point where we are today. Fantastic.
The guy in the famous 40-minute video, the beginning of which explains RM vs IM, appears to make claims that he's too busy and doesn't have time writing research papers. Wow. He discovered IM on his own probably, and reached the conclusion that he's discovered something no one else has discovered and should be writing a research paper. Jeez.