Taking a Towers-of-Hanoi game as an example
- Hanoi
- Moving disks around
- Move them all over to the other side, and you win
- Move them away again, and you un-win
use Test; | |
sub double($n) { | |
my @digits = $n.comb; | |
my @result; | |
my $last; | |
for @digits -> $d { | |
my $dd = $d * 2; | |
if $dd >= 10 { | |
$last++; |
my $MAX_N = 20; | |
my $TRIALS = 10_000; | |
for 1 .. $MAX_N -> $N { | |
my @lengths = loop-length(random-mapping($N)) xx $TRIALS; | |
my $average = ([+] @lengths) / @lengths; | |
my $analytical = analytical($N); | |
my $percent_error = abs($analytical - $average) / $analytical * 100; | |
FIRST say " N average analytical (error)"; |
import qualified Data.MultiSet as MultiSet | |
import qualified Data.Set as Set | |
limit :: Int | |
limit = 100 | |
products :: MultiSet.MultiSet Int | |
products = MultiSet.fromList [ x * y | x <- [2..limit], y <- [x+1..limit-x] ] | |
sums_with_unambiguous_products :: Set.Set Int |
import qualified Data.MultiSet as MultiSet | |
limit :: Int | |
limit = 100 | |
products :: MultiSet.MultiSet Int | |
products = MultiSet.fromList [ x * y | x <- [2..limit], y <- [x+1..limit-x] ] | |
solutions :: [(Int, Int)] | |
solutions = [(4, 13)] |
solutions :: [(Int, Int)] | |
solutions = [(4, 13)] | |
main :: IO () | |
main = mapM_ print solutions |
[color] | |
ui = auto | |
[color "branch"] | |
current = yellow reverse | |
local = yellow | |
remote = green | |
[color "diff"] | |
meta = white reverse | |
frag = white bold | |
old = red bold |
Initiation phase | |
================ | |
Adventure::TwoRoomsConnected | |
Adventure::TwoRoomsDisconnected | |
Adventure::DirectionAliased | |
Adventure::RoomMadeDark | |
Adventure::ThingPlaced | |
Adventure::ThingMadeAContainer |
$ nom | |
> my $a = 42; | |
42 | |
> $a = 43 | |
43 | |
> my $a = 5 | |
5 | |
> $a | |
43 | |
> |
17:19 < mark_weaver> masak: In Scheme, a single macro invocation can expand into several procedures. furthermore, a macro can | |
expand into another macro use, which later expands into something different. in general, macro expansion | |
can split up and combine pieces of code into a very different arrangement. the lexical contours can only | |
be determined after macro expansion. | |
17:20 < LeoNerd> Ooooh.. that's another good point | |
17:21 < mark_weaver> masak: therefore, it seems to me that you're very much on the wrong track. | |
17:21 < masak> interesting. I will try to process this. | |
17:21 < mark_weaver> I suggest that you read some papers on hygienic macros. let me dig up some references. | |
17:21 < LeoNerd> Yah; I'm still with "macros are sort of like rewrites of the source code" in CPP-style.. only nicer | |
17:21 < masak> mark_weaver: excellent. that was my next question :) |