(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
// Copyright (c) 2021 Stoiko Todorov | |
// This work is licensed under the terms of the MIT license. | |
// For a copy, see https://opensource.org/licenses/MIT. | |
// What this function does: | |
// Rasterizes a single Field Of View octant on a grid, similar to the way | |
// field of view / line of sight / shadowcasting is implemented in some | |
// roguelikes. | |
// Uses rays to define visible volumes instead of tracing lines from origin | |
// to pixels. |
This post also appears on lisper.in.
Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.
Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):
The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.
Beginning Regex | |
Intro to Regular Expressions by Michael Fitzgeral | |
http://www.amazon.com/Introducing-Regular-Expressions-ebook/dp/B008K9OGDA/ref=sr_1_2?ie=UTF8&qid=1374171971&sr=8-2&keywords=Regular+Expressions | |
Using Regular Expressions in Ruby: Part 1 by Nell Shamrell | |
https://www.bluebox.net/insight/blog-article/using-regular-expressions-in-ruby-part-1-of-3 | |
Intermediate Regex |
All of these resources were extremely valuable as I researched regex, finite state machines, and regex in Ruby. Check them out, they're full of fantastic information! | |
Articles | |
"Exploring Ruby's Regular Expression Algorithm" by Pat Shaughnessy | |
http://patshaughnessy.net/2012/4/3/exploring-rubys-regular-expression-algorithm | |
"Finite State Machines and Regular Expressions" by Eli Bendersky | |
http://www.gamedev.net/page/resources/_/technical/general-programming/finite-state-machines-and-regular-expressions-r3176 | |
"Regular Expression Matching Can Be Simple and Fast" by Russ Cox |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
(The blockquote style does not look so well so I just pasted directly, but these are all quoted from the links in the bottom of this page)
You should not implement to_str
unless your object acts like a string, rather than just having a string representation. The only core class that implements to_str
is String itself.
[to_i and to_s] are not particularly strict: if an object has some kind of decent representation as a string, for example, it will probably have a to_s method… [to_int and to_str] are strict conversion functions: you implement them only if you object can naturally be used every place a string or an integer could be used.
to_str
is used by methods such as String#concat
to convert their arguments to a string. Unlike to_s, which is supported by almost all classes, to_str
is normally implemented only by those classes that act like strings. Of the built-in classes, only Exception
and String
implement to_str
class Snatcher < BasicObject | |
C = ::Object.new | |
class << C | |
def abduct_method(meth, arity) | |
ObjectSpace.each_object(Module) do |mod| | |
next if mod.kind_of? Class | |
if mod.instance_methods.include?(meth) | |
return mod.instance_method(meth) | |
end |