Skip to content
Prev 180323 / 398513 Next

Simulation

Barry Rowlingson wrote:
maybe quasi ;)
yeah, that's the implementation level.  a typical recipe would not say
'for n from 1 to 6, break the nth egg'.  it'd rather say 'break the
eggs', which is closer to 'apply break to the eggs'.  you do of course
break the eggs sequentially (or?), but that's below the abstraction
useful for the recipe purpose. 

the example is quite good, in fact:  the lapply approach is more
appropriate, since what you're interested in is actually starting with
six eggs and ending with six broken eggs;  neither the particular order
you might have chosen, nor whether you break the eggs sequentially or in
parallel.  in a sense, 'for n from 1 to 6, break the nth egg' is a
particular operationalization of 'apply break to the eggs'.
but you do apply the break function to the ith egg in a for loop?  and
actually, the procedural way fo breaking eggs can be easily written
without a for loop, e.g., using a ruby-ish notation:

    eggs.each { |egg| break egg }

which says, 'for each egg, take the egg and break it', without using a
dummy index.

vQ