<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<!-- name="generator" content="blosxom/2.0" -->
<channel  rdf:about="http://perlgeek.de/blog-en/">
    <title>Perlgeek.de   </title>
    <link>http://perlgeek.de/blog-en/</link>
    <description>Perl and Programming Blog.</description>
</channel>

  <item rdf:about="http://perlgeek.de/blog-en/perl-6/rakudo-memory-leaks.html">
 <title>Fixing Rakudo Memory Leaks</title>
  <link>http://perlgeek.de/blog-en/perl-6/rakudo-memory-leaks.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Thu, Aug 26 13:52:12 2010</pubDate>
    <description>&lt;!-- 1282823532 --&gt;

&lt;p&gt;Rakudo has been leaking memory for a few month. The other day, after some
nagging, Will Coleda identified a memory leak, and Tyler Curtis &lt;a
href=&quot;http://github.com/rakudo/rakudo/commit/3a339ee8ab3a72867fe914ec9c689e1f5a890645&quot;&gt;fixed
it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now we can again make long-running processes with Rakudo. For example for
my talk at YAPC::EU I plotted a &lt;a
href=&quot;http://perlgeek.de/talks/2010/yapceu-p6-realworld/resonance.png&quot;&gt;resonance 
curve&lt;/a&gt;. For that I needed to start a new Rakudo process for every data
point because it would leak so badly that it died after processing a few data
points. Now I recalculated a whole curve in one process, with memory usage not
exceeding 200MB of virtual mem.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://perlgeek.de/images/blog/res2.png&quot; width=&quot;702&quot; height=&quot;506&quot;
alt=&quot;resonance curve&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I also had some fun recalculating a mandelbrot fractal in a size that would
previously make Rakudo segfault or consume too much memory.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://perlgeek.de/images/blog/mandel-color.png&quot; width=&quot;1001&quot;
height=&quot;1001&quot; alt=&quot;Mandelbrot fractal, rendered by Rakudo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;(Rendered with &lt;a href=&quot;http://github.com/colomon/mandelbrot/&quot;&gt;colomon's
mandelbrot code)&lt;/a&gt;).&lt;/p&gt;



</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/pascal-triangle.html">
 <title>Pascal's Triangle in Perl 6</title>
  <link>http://perlgeek.de/blog-en/perl-6/pascal-triangle.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Wed, Aug 25 17:03:32 2010</pubDate>
    <description>&lt;!-- 1282748612 --&gt;

&lt;p&gt;Today on IRC, Larry Wall showed this piece of Perl 6 code, which he wrote
for &lt;a href=&quot;http://rosettacode.org/wiki/Pascal%27s_triangle#Perl_6&quot;&gt;Rosetta
Code&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;sub&lt;/span&gt; pascal { [&lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;]&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@p&lt;/span&gt; { [&lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@p&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;Z+&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@p&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;] } &lt;span class=&quot;synStatement&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt; }&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; pascal[&lt;span class=&quot;synStatement&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;10&lt;/span&gt;]&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;perl&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;# output (reformatted for easy readbility):&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;# ([1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 2, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 3, 3, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 4, 6, 4, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 5, 10, 10, 5, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 6, 15, 20, 15, 6, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 7, 21, 35, 35, 21, 7, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 8, 28, 56, 70, 56, 28, 8, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 9, 36, 84, 126, 126, 84, 36, 9, 1])&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;That's &lt;a href=&quot;http://en.wikipedia.org/wiki/Pascal%27s_triangle&quot;&gt;Pascal's
triangle&lt;/a&gt;, generated in one line of Perl 6.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;...&lt;/code&gt; is the series operator, which generates lists by
feeding the previous value(s) (here always one array) to the generating
block on its left, until it reaches the goal on the right (in this case
&quot;whatever&quot;, which means it returns a lazy, infinite list).&lt;/p&gt;

&lt;p&gt;So for example if the previous item was the array &lt;code&gt;[1, 2, 1]&lt;/code&gt;,
the code block evaluates &lt;code&gt;0, 1, 2, 1 Z+ 1, 2, 1, 0&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Z&lt;/code&gt; is the zip operator, &lt;code&gt;Z+&lt;/code&gt; is pairwise addition
(ie adding the pairs that the zip operator produced). In our example that
leads to &lt;code&gt;0+1, 1+2, 2+1, 1+0&lt;/code&gt; or &lt;code&gt;1, 3, 3, 1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It takes a while to get used to the meta operators and the series operator,
but once you've understood them, you can do pretty neat things with them.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/not-zero-sum.html">
 <title>Programming Languages Are Not Zero Sum</title>
  <link>http://perlgeek.de/blog-en/perl-6/not-zero-sum.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Mon, Aug 23 10:54:54 2010</pubDate>
    <description>&lt;!-- 1282553694 --&gt;

&lt;p&gt;From &lt;a href=&quot;http://en.wikipedia.org/wiki/Zero-sum&quot;&gt;Wikipedia, the free
    encyclopedia&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;
    In game theory and economic theory, zero-sum describes a situation
    in which a participant's gain or loss is exactly balanced by the losses or
    gains of the other participant(s). If the total gains of the participants
    are added up, and the total losses are subtracted, they will sum to zero.
&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Being advocate, implementor, tester and co-designer of a &lt;a
href=&quot;http://perl6.org/&quot;&gt;new programming language&lt;/a&gt;, I often hear objections
along the lines of &lt;em&gt;you are killing &lt;a
href=&quot;http://www.perl.org/&quot;&gt;$other_programming_language&lt;/a&gt;&lt;/em&gt;, combined
with a mixture of fear and resentment. People are afraid that having a new
player on the market will decrease
market share of their own, favorite programming language.&lt;/p&gt;

&lt;p&gt;While I can understand these thinking patterns, there is no reason for
concern. The market for programming languages is not a zero-sum situation.
While I don't have hard data, I have the impression that the programming job
sector is growing, and &lt;a
href=&quot;http://www.bls.gov/oco/ocos303.htm#projections_data&quot;&gt;the US
government expects it to grow&lt;/a&gt; further, too.&lt;/p&gt;

&lt;p&gt;Certainly the &lt;a
href=&quot;http://upload.wikimedia.org/wikipedia/commons/7/77/World-Population-1800-2100.png&quot;&gt;growth
of world population&lt;/a&gt; sets a rapidly increasing baseline, and even if we
assume a constant percentage of all people related to programming in some way,
the total number of programmers rises, and will continue for quite some
time.&lt;/p&gt;

&lt;p&gt;(I'm pointing to some resources about programming jobs, and I fully realize that
it's not the same as number of overall programmers; but it's easier to get
data for jobs, and I do think that the general trend statements are true for
both).&lt;/p&gt;

&lt;p&gt;So as long as the total number of programmers increases, a decrease in
relative market share doesn't automatically mean a loss. In fact &lt;a
    href=&quot;http://duartes.org/gustavo/blog/post/programming-language-jobs-and-trends&quot;&gt;the
job trends show an increase for &quot;scripting&quot; languages&lt;/a&gt;, and while Ruby is
certainly the winner in terms of growth, Python, Perl and PHP win too!&lt;/p&gt;

&lt;p&gt;Non-job data shows for example a &lt;a
href=&quot;http://stats.cpantesters.org/graphs12.html&quot;&gt;noisy but steady growth
of uploads to the Comprehensive Perl Archive Network (CPAN)&lt;/a&gt; -- data from a
programming language that is often perceived as a loser of ruby's and python's
success.&lt;/p&gt;

&lt;p&gt;A recent &lt;a
href=&quot;http://linuxtrends.com/linux-distribution-popularity-trends/&quot;&gt;Linux
distribution trend analysis&lt;/a&gt; fell into the same trap: it shows
&lt;strong&gt;relative&lt;/strong&gt; numbers of search terms, and talks about a decline
for all distributions except Ubuntu. Again I don't have hard numbers (the
mirror infrastructure of most Linux distributions makes it nearly impossible
to get accurate download counts), but I haven't seen any evidence that total
usage numbers of any of the Linux distributions actually decreased.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/state-of-regex-modifiers.html">
 <title>The State of Regex Modifiers in Rakudo</title>
  <link>http://perlgeek.de/blog-en/perl-6/state-of-regex-modifiers.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Mon, Aug 16 17:16:15 2010</pubDate>
    <description>&lt;!-- 1281971775 --&gt;

&lt;p&gt;During the last one and a half month, I've been working on making regex
modifiers easily available in Rakudo.&lt;/p&gt;

&lt;p&gt;The regex compiler itself has to support only a few of the adverbs that can
be applied to regexes; those include :ignorecase, :sigspace, :ignoremark and
:continue/:pos. NQP-rx, the regex engine that Rakudo uses under the hood,
supports those (except :ignoremark), so previously you could write&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;ABC&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;~~&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;i abc&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt; {
    &lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;case insensitive match&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
}
&lt;/pre&gt;


&lt;p&gt;But not&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;ABC&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;~~&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;rx:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;abc&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt; {
    &lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;case insensitive match&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
}
&lt;/pre&gt;

&lt;p&gt;nor &lt;code&gt;m:i/abc/&lt;/code&gt;, for that matter.&lt;/p&gt;

&lt;p&gt;I've patched Rakudo to actually recognize those adverbs outside of the
regex, and also for &lt;code&gt;s///&lt;/code&gt; substitutions.&lt;/p&gt;

&lt;p&gt;Another category of adverbs are those that apply to regex calls, not to the
compilation of a regex. Among those are :global/:g, :overlap/:ov, :nth($n),
:x. I've implemented those for substitutions, but implementing them for
&lt;code&gt;m//&lt;/code&gt; turns  out to be quite a bit harder.&lt;/p&gt;

&lt;p&gt;The reason is the return value: each regex match returns a Match object,
which can store positional and named parts. &lt;a
href=&quot;http://pugscode.org/syn/S05.html&quot;&gt;S05&lt;/a&gt; says that regex matches
with multiple results should return a single match object, with all results as
positional parts. It can be distinguished from a normal match object by
evaluating it in slice context... which Rakudo doesn't support yet.&lt;/p&gt;

&lt;p&gt;Now the &lt;code&gt;subst&lt;/code&gt; method and thus &lt;code&gt;s///&lt;/code&gt; are
implemented by calling &lt;code&gt;.match(:global, ...)&lt;/code&gt;, and without slice
context, it can't distinguish between multiple matches, and a single match
with subcaptures. And so my changes to the global match broke the
substitution, and I see no easy way to fix it.&lt;/p&gt;

&lt;p&gt;Anyway, here are a few examples of what works today:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;$_&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;ab12fg34&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synStatement&quot;&gt;s:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/\d/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# output: abXXfgXX&lt;/span&gt;


&lt;span class=&quot;synIdentifier&quot;&gt;$_&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Hello, World&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;# :ii is the same as :samecase&lt;/span&gt;
&lt;span class=&quot;synStatement&quot;&gt;s:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;ii&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;world&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;perl&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# output: Hello, Perl&lt;/span&gt;

&lt;span class=&quot;synIdentifier&quot;&gt;$_&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;I did not know that that work together&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synStatement&quot;&gt;s:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;2nd&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;that&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;they&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# output: I did not know that they work together&lt;/span&gt;
&lt;/pre&gt;

 
</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/cool.html">
 <title>What is the &quot;Cool&quot; class in Perl 6?</title>
  <link>http://perlgeek.de/blog-en/perl-6/cool.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Thu, Aug 12 15:28:39 2010</pubDate>
    <description>&lt;!-- 1281619719 --&gt;

&lt;p&gt;In Perl, subroutine and operator names determine what happens, usually not
the type of the arguments. Instead the arguments are coerced to a type on
which the operation makes sense:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;uc&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;34&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;synComment&quot;&gt;# coerces 34 to a string, and upper-cases it&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;    &lt;span class=&quot;synComment&quot;&gt;# converts &amp;quot;2&amp;quot; to a number before adding&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;To make things more extensible, the &lt;code&gt;uc&lt;/code&gt; function re-dispatches
to the &lt;code&gt;uc&lt;/code&gt; method on its argument. So for the example above to
work, we need an &lt;code&gt;uc&lt;/code&gt; function in Int. And in Array, so that
&lt;code&gt;@a.uc&lt;/code&gt; works. And so on.&lt;/p&gt;

&lt;p&gt;The original approach was to stuff all these methods into &lt;code&gt;Any&lt;/code&gt;,
the base class of the object hierarchy. Which kinda worked, but also meant
that all user-defined classes ended up having some few hundreds methods to
start with. Not good.&lt;/p&gt;

&lt;p&gt;These days, the type &lt;code&gt;Cool&lt;/code&gt; fills this niche: most built-in types
(all that are meant to be used in that polymorphic way) inherit from Cool, so
the &lt;code&gt;uc&lt;/code&gt; method is actually defined in class &lt;code&gt;Cool&lt;/code&gt;,
coerces to string, and then re-dispatches to the internal logic that actually
does the upper-casing.&lt;/p&gt;

&lt;p&gt;The name either stands for &lt;em&gt;&lt;strong&gt;C&lt;/strong&gt;onvenient
    &lt;strong&gt;o&lt;/strong&gt;bject &lt;strong&gt;o&lt;/strong&gt;riented
    &lt;strong&gt;l&lt;/strong&gt;oopback&lt;/em&gt;, or just expresses that that most
built-ins are cool with an argument of that type.&lt;/p&gt;

&lt;p&gt;If users want to write a type that can be used like a built-in type now
just inherit from &lt;code&gt;Cool&lt;/code&gt;, and define coercion methods to other
built-in types. If the types don't inherit from &lt;code&gt;Cool&lt;/code&gt;, they are
more light-weight, and less magic. There's more than one way to do it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Cool&lt;/code&gt; is a class (and not a role), because classes are mutable;
so if you want to inject behavior into nearly all built-in types, augmenting
&lt;code&gt;Cool&lt;/code&gt; is an option (though usually considered evil, and should not
be done lightly).&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/perlmonks-questions.html">
 <title>Perl 6 Questions on Perlmonks</title>
  <link>http://perlgeek.de/blog-en/perl-6/perlmonks-questions.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Tue, Aug 10 11:18:42 2010</pubDate>
    <description>&lt;!-- 1281431922 --&gt;
&lt;p&gt;Since the Rakudo Star release, there has been a noticeable increase in Perl
6 questions on perlmonks - a good sign, because it means people are using
it.&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=853975&quot;&gt;Array interpolation
        in Rakudo&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=853727&quot;&gt;Rakudo build
        problems&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=853573&quot;&gt;Perl6, latest
        Rakudo bug or error on my part?&lt;/a&gt; (parsing issue related to missing
        whitespace).&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=853149&quot;&gt;Perl6, modifying
        @*INC&lt;/a&gt; (another ws parsing issue)&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=853113&quot;&gt;Perl6's
        LWP::Simple&lt;/a&gt; -- seemingly an installation issue&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=852900&quot;&gt;Perl 6, defining a
        hash with interpolated string&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I've assembled this list by looking through the 100 newest nodes in &lt;a
href=&quot;http://www.perlmonks.org/?node=Seekers%20of%20Perl%20Wisdom&quot;&gt;Seekers of
Perl Wisdom&lt;/a&gt;, which makes it 6% of the questions asked, or on average 1 per
day (used to be around 1 per week).&lt;/p&gt;

&lt;p&gt;Most of the questions are related to environmental issues
(building/installing stuff), or beginner's questions related to syntax.&lt;/p&gt;

&lt;p&gt;It's good to see the questions flowing in, and I hope that we'll soon see
more questions where I can show off cool Perl 6 features in the answers
:-).&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/notes-from-yapc-hackathon.html">
 <title>Notes from the YAPC::EU 2010 Rakudo hackathon</title>
  <link>http://perlgeek.de/blog-en/perl-6/notes-from-yapc-hackathon.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Fri, Aug  6 16:48:40 2010</pubDate>
    <description>&lt;!-- 1281106120 --&gt;

&lt;p&gt;At YAPC::EU 2010 we had a long discussion about Perl 6, Rakudo and related
matters. Here are some (very incomplete) notes of the ongoing discussions and
results.&lt;/p&gt;

&lt;h2 id=&quot;attendees&quot;&gt;Attendees&lt;/h2&gt;

&lt;p&gt;Patrick Michaud, Jonathan Worthington, Carl Mäsak, Moritz Lenz, Gabor
Szabo, and a fluctuation of other Perl 6 hackers.&lt;/p&gt;

&lt;h2 id=&quot;speed&quot;&gt;Speed&lt;/h2&gt;
&lt;p&gt;What can we do to improve Rakudo's performance?&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;jnthn_s_grant_proposal_for_a_low_level_meta_object_protocol&quot; class=&quot;item&quot;&gt;jnthn's grant proposal for a low-level meta object protocol&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;See
&lt;a href=&quot;http://news.perlfoundation.org/2010/07/hague-grant-application-meta-m.html&quot;&gt;http://news.perlfoundation.org/2010/07/hague-grant-application-meta-m.html&lt;/a&gt;.
Will probably bring the biggest speed improvement of all options we have under
our control&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;rakudo_built_in_optimizations&quot; class=&quot;item&quot;&gt;Rakudo built-in optimizations&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;Most Rakudo built-ins are written for correctness first, and without a good
feeling for what constructs are fast and what aren't. A thorough review (and
preferably profiling) could bring decent speed improvements, as the case of
int ranges showed.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;garbage_collector&quot; class=&quot;item&quot;&gt;Garbage collector&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;Parrot's GC is... suboptimal. To be gentle.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;optimization_framework&quot; class=&quot;item&quot;&gt;Optimization framework&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;We will try to convince people that Tyler Curtis' optimization framework for
PAST and POST should be shipped with parrot (probably compile PIRs in &lt;code&gt;ext/&lt;/code&gt;,
just like NQP-rx does it now). Using that, we can do constant folding&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;moving_stuff_to_compile_time&quot; class=&quot;item&quot;&gt;Moving stuff to compile time&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;Number parsing needs to be moved to compile time.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;

&lt;h2 id=&quot;what_do_we_need_to_keep_hacking&quot;&gt;What do we need to keep hacking?&lt;/h2&gt;
&lt;p&gt;Brought up by Gabor&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;money&quot; class=&quot;item&quot;&gt;Money&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;We do much volunteer work, but when we get funding, we can devote more time to
hacking&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;travel_conferences&quot; class=&quot;item&quot;&gt;Travel/Conferences&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;We'd like to get together a few times (2? 3? 4?) a year, in real life.&lt;/p&gt;
&lt;p&gt;Funding and organization would be very welcome&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;short_time_funding&quot; class=&quot;item&quot;&gt;Short-time funding&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;It would be nice to have a way to have funding available much more quickly
than through the usual grant process, which tends to be longish.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;h2 id=&quot;rakudo_star_feedback&quot;&gt;Rakudo Star feedback&lt;/h2&gt;
&lt;p&gt;Good: It worked. It did what we wanted it to.&lt;/p&gt;
&lt;p&gt;Bad:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;It lacked a module installer (It shipped proto, but didn't install it).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Compilation takes too much memory. pmichaud will try a hack to split the
setting, which would solve that problem.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There was some discussion about the roles + outer scopes bugs, which was way
over my head. It seems to be related to the fact that parrot has two outer
chains for nested blocks: one at compile time, one at runtime. Since role
methods are flattened into classes, there compile time outer block is actually
different than where it runs, and that  screws up ... forget it, somebody else must describe it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lack of modules - doesn't seem to bee a big problem&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lack of features: not a big problem.&lt;/p&gt;
&lt;p&gt;Biggest complaints: missing perl6doc. Missing non-blocking IO, binary file
support.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Prefix paths with spaces are not supported :(&lt;/p&gt;
&lt;p&gt;jnthn: &amp;quot;I actually tried to write a C program that binary patches the perl6
executable to allow spaces in path names. It almost worked.&amp;quot;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We will try to advocate compilation to PBC, not PIR - once that's supported.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;proto_pls&quot;&gt;Proto/Pls&lt;/h2&gt;
&lt;p&gt;Proto needs to be end-of-life'd.&lt;/p&gt;
&lt;p&gt;It confuses people that there are two different project lists, and the lists
diverge.&lt;/p&gt;
&lt;p&gt;We would like to decentralize the module list somehow. Still open how.&lt;/p&gt;

&lt;p&gt;People don't release Perl 6 modules, because there's no need so far, and
it's tedious to add the version name in each .pm/.pm6 file. We might need to
come up with a clever idea for that.&lt;/p&gt;

&lt;h2 id=&quot;backend_diversity&quot;&gt;Backend diversity&lt;/h2&gt;
&lt;p&gt;Additionally to the parrot backend, we want to run Perl 6 code on other
virtual machines.&lt;/p&gt;
&lt;p&gt;jnthn will work on a .NET/CLR port. He wants to prototype the new low-level
class composition code in .NET anyway, which will provide the basic
foundations for running NQP.&lt;/p&gt;
&lt;p&gt;pmichaud wants to explore javascript on V8 as a possible backend. &amp;quot;I managed
PIR, I'll certainly manage javascript&amp;quot; :-)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Huge time sink, but still worth doing it&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Apache runtime library might be worth looking into&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;risks: stalled refactors are dangerous (see: PHP 6, cardinal (the
ruby-on-parrot compiler))&lt;/p&gt;
&lt;p&gt;We want to avoid fragmentation into many subprojects&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We want to increase the number of possible contributors to rakudo by
enabling non-parrot people to contribute.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Code for different backends will be maintained as directories in Rakudo and
NQP, not as branches.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;pir:: things will be hidden behind an nqp:: abstraction layer&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;attracting_contributors&quot;&gt;Attracting contributors&lt;/h2&gt;
&lt;p&gt;Moritz wants to continue with the &amp;quot;weekly&amp;quot; challenges, but runs out of ideas.
Add ideas to &lt;a href=&quot;http://svn.pugscode.org/pugs/misc/helpnow/README&quot;&gt;http://svn.pugscode.org/pugs/misc/helpnow/README&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We will try to apply patches faster, thus encouraging people who already did
the first step.&lt;/p&gt;

&lt;h2 id=&quot;documentation&quot;&gt;Documentation&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;in p5 pod for now, so that people can contribute easily&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;masak and szabgab expressed interest in working on pod6 tools&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

 
</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/my-first-yapc.html">
 <title>My first YAPC - YAPC::EU 2010 in Pisa</title>
  <link>http://perlgeek.de/blog-en/perl-6/my-first-yapc.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Fri, Aug  6 16:37:07 2010</pubDate>
    <description>&lt;!-- 1281105427 --&gt;

&lt;p&gt;This week I attended my first international Perl conference, the &lt;a
href=&quot;http://conferences.yapceurope.org/ye2010/index.html&quot;&gt;YAPC::EU 2010 in
Pisa, Italy&lt;/a&gt;. I very much enjoyed it.&lt;/p&gt;

&lt;p&gt;I arrived a few days earlier, and spent the time visiting Pisa, talking
with old and new friends, and did some collaborative hacking. I especially
enjoyed meeting people with whom I had had only contact via Internet so far,
and found all of them to be very nice in meat space.&lt;/p&gt;

&lt;p&gt;On Tuesday, the day before the conference started officially, a group of
Perl 6 hackers met and discussed topics around Perl 6 and Rakudo. I recall
talking with Patrick Michaud, Jonathan Worthington, Carl Mäsak, Paweł
Murias, Gabor Szabo, smash (I can't spell his full name correctly from memory,
sorry for that), and we have a very productive discussion (about 5 hours or
so). Notes from the discussion will be published later.&lt;/p&gt;

&lt;p&gt;On Wednesday the actual conference started, and there were plenty of very
interesting talks, and very amusing lightning talks. I generally like the
humor that is widespread in the Perl community.&lt;/p&gt;

&lt;p&gt;On Thursday I continued to attend nice and informative talks, and also gave
a talk on my own. It was about physical modelling with Perl 6, and in general
the feedback was very positive, and somebody even commented that while he
didn't understand everything I wrote, it reminded him that it was important to
learn Perl 6 now. Win \o/. (There was also some criticism, but from somebody
who apparently hasn't read &lt;a
href=&quot;http://conferences.yapceurope.org/ye2010/talk/2949&quot;&gt;the abstract&lt;/a&gt;;
the &quot;write-only&quot; meme seems to apply to perl bloggers, not code). You can find
&lt;a href=&quot;http://perlgeek.de/talks/2010/yapceu-p6-realworld/&quot;&gt;the slides
to my talk here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Firday was the day of my departure too - sadly I had to leave after the
first talk, and missed the rest of the day, including the closing keynote by
mst (I did attend a talk of his) and the traditional auction.&lt;/p&gt;

&lt;p&gt;I especially enjoyed...&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;meeting Patrick, Larry, Gloria, Aaron, Gabor and many others for the
    first time in real-life&lt;/li&gt;
    &lt;li&gt;a thorough, high-bandwith discussion with Larry, Jonathan, Patrick and
    Carl about p6 spec questions, and the Perl 6 discussions mentioned
    earlier&lt;/li&gt;
    &lt;li&gt;a lightning talk &lt;em&gt;imagine you're in a data center with no
    connection to the outside, and you accidentally executed &lt;code&gt;chmod -x
    chmod&lt;/code&gt;. What would you do?&lt;/em&gt;&lt;/li&gt;
    &lt;li&gt;good Italian Pizzas (although I had to wait 50 minutes for one of
    them)&lt;/li&gt;
&lt;!--    &lt;li&gt;discovering that the cable connection in the hotel did not block
TCP port 53&lt;/li&gt; --&gt;
    &lt;li&gt;A talk by Tim Bunce, where he demonstrated database access in Perl 6
    both with libraries that do native calls, and through the Blizkost project
    using the Perl 5 DBI/DBD::SQLite modules&lt;/li&gt;
    &lt;li&gt;the general relaxed attitude in the Perl community, where people help
    each other, and don't seem to be easily offended (at least in meat space
    :)&lt;/li&gt;
    &lt;li&gt;being surrounded by many other geeks&lt;/li&gt;
    &lt;li&gt;realizing that several Perl hackers brought their family to the
    conference&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It was an overwhelming experience, and I look forward to my next YAPC!&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/gabor-keep-going.html">
 <title>Gabor: Keep going</title>
  <link>http://perlgeek.de/blog-en/perl-6/gabor-keep-going.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Mon, Jul 19 22:36:05 2010</pubDate>
    <description>&lt;!-- 1279571765 --&gt;

&lt;p&gt;After reading &lt;a
href=&quot;http://blogs.perl.org/users/gabor_szabo/2010/07/promoting-perl-is-fun.html&quot;&gt;this
blog post&lt;/a&gt;, I just want to say: keep going.&lt;/p&gt;

&lt;p&gt;Gabor does really awesome things for Perl (and especially for Perl 6, which
I tend to notice more): beginner's tutorials, screencasts, training courses,
writes an IDE and so on. If his primary interest was his own success, his
priorities would be quite different.&lt;/p&gt;

&lt;p&gt;I hope that Gabor doesn't pay too much attention to the hostilities from
parts of the Perl community, and I wish him and us all the best for his &lt;a
href=&quot;http://news.perlfoundation.org/2010/06/hague-grant-application-perl-e.html&quot;&gt;current
project&lt;/a&gt;.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/contribute-now-hash-pick.html">
 <title>This Week's Contribution to Perl 6 Week 9: Implement Hash.pick for Rakudo</title>
  <link>http://perlgeek.de/blog-en/perl-6/contribute-now-hash-pick.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Tue, Jul 13 15:22:47 2010</pubDate>
    <description>&lt;!-- 1279027367 --&gt;

&lt;p&gt;For this week's contribution to Perl 6 we ask you to implement the
&lt;code&gt;Hash.pick&lt;/code&gt; method (which does a weighted random selection) for
Rakudo.&lt;/p&gt;

&lt;p&gt;(&lt;a
    href=&quot;http://perlgeek.de/blog-en/perl-6/contribute-now-announce.html&quot;&gt;Introduction
    to this series of challenges&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;Background&lt;/h2&gt;

&lt;p&gt;In Perl 6 the &lt;code&gt;List&lt;/code&gt; class has a method called &lt;code&gt;pick&lt;/code&gt;,
which randomly selects one item from a list. It has a few more options
too:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;a b c&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;       &lt;span class=&quot;synComment&quot;&gt;# pick one random element&lt;/span&gt;
&lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;a b c&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;    &lt;span class=&quot;synComment&quot;&gt;# pick two distinct, random elements&lt;/span&gt;
&lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;a b c&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;replace&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# pick two random elements, it's ok&lt;/span&gt;
                           &lt;span class=&quot;synComment&quot;&gt;# if they are the same&lt;/span&gt;
&lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;a b c&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;(&lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;    &lt;span class=&quot;synComment&quot;&gt;# return a random permutation of the elements&lt;/span&gt;
&lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;a b c&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;(&lt;span class=&quot;synStatement&quot;&gt;*,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;replace&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# infinite, random stream of elements&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;This is already &lt;a
href=&quot;http://github.com/rakudo/rakudo/blob/master/src/core/Any-list.pm#L165&quot;&gt;implemented
through several multi methods in Rakudo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now the specification &lt;a
href=&quot;http://perlcabal.org/syn/S32/Containers.html#Bag&quot;&gt;describes such a
method for hashes too&lt;/a&gt; (actually it talks about Bags, but Rakudo doesn't
have Bags yet. Pretend it says &quot;Hash&quot; instead). It assumes that each value in
the hash is numeric, and that the value is a weight that determines the
probability of picking one value. For example&lt;/p&gt;

&lt;pre&gt;
{&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt;}&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;synComment&quot;&gt;# returns 'a' with probability 1/3&lt;/span&gt;
                        &lt;span class=&quot;synComment&quot;&gt;# and 'b' with probability 2/3&lt;/span&gt;

{&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt;}&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;(&lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;synComment&quot;&gt;# &amp;lt;a b b&amp;gt; with probability 1/3&lt;/span&gt;
                           &lt;span class=&quot;synComment&quot;&gt;# &amp;lt;b a b&amp;gt; with probability 1/3&lt;/span&gt;
                           &lt;span class=&quot;synComment&quot;&gt;# &amp;lt;b b a&amp;gt; with probability 1/3&lt;/span&gt;
{&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;0.5&lt;/span&gt;}&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;(&lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt;) &lt;span class=&quot;synComment&quot;&gt;# dies, because the weights aren't all integers&lt;/span&gt;
{&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;0.5&lt;/span&gt;}&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;(&lt;span class=&quot;synStatement&quot;&gt;*,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;replace&lt;/span&gt;)  &lt;span class=&quot;synComment&quot;&gt;# ok &lt;/span&gt;
&lt;/pre&gt;



&lt;h2&gt;What you can do&lt;/h2&gt;

&lt;p&gt;Implement Hash.pick. It's ok if your patch doesn't cover all cases. It
would be nice if it supported non-integer weights.&lt;/p&gt;

&lt;p&gt;Hint: this could be done by storing a list of accumulated weights, and a
list of keys.&lt;/p&gt;

&lt;pre&gt;
{&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;2.5&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;}

&lt;span class=&quot;synComment&quot;&gt;# could translate to &lt;/span&gt;
&lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@keys&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; (&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@accumulated_weights&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; (&lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;3.5&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;4.5&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;synComment&quot;&gt;# now pick a random number between 0 and 4.5,&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;# find the next-highest index in @accumulated_weights&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;# with a binary search, and then use that to obtain the key.&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;Of course other schemes are fine too.&lt;/p&gt;

&lt;p&gt;Second hint: because it takes quite some time to recompile Rakudo, it is 
probably easier to implement the actual logic in a function
in a normal source file first, and only later move it into src/core/Hash.pm.&lt;/p&gt;

&lt;h2&gt;Submission&lt;/h2&gt;

&lt;p&gt;Please submit your source code to the &lt;a
href=&quot;mailto:perl6-compiler@perl.org&quot;&gt;perl6-compiler@perl.org&lt;/a&gt; mailing
list (and put moritz@faui2k3.org on CC,
because the mailing list sometimes lack quite a bit).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; there's one submission on the perl6-compiler
mailing list already, which looks pretty good.&lt;/p&gt;



</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/want-to-write-shiny-graphics.html">
 <title>Want to write shiny SVG graphics with Perl 6? Port Scruffy!</title>
  <link>http://perlgeek.de/blog-en/perl-6/want-to-write-shiny-graphics.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Mon, Jul 12 15:43:27 2010</pubDate>
    <description>&lt;!-- 1278942207 --&gt;

&lt;p&gt;First let my apologize for waiting so long to come up with a new 
&lt;a href=&quot;http://perlgeek.de/blog-en/perl-6/contribute-now-announce.html&quot;&gt;&quot;weekly&quot;
    Perl 6 challenge&lt;/a&gt; - I'm running out of ideas, and the one I have left needs
more time to prepare.&lt;/p&gt;

&lt;p&gt;Instead I want to motivate you to help porting the ruby &lt;a
href=&quot;http://scruffy.rubyforge.org/&quot;&gt;scruffy charting library&lt;/a&gt; to Perl 6.
It can generate &lt;a
    href=&quot;http://replay.waybackmachine.org/20080625015853/http://scruffy.rubyforge.org/&quot;&gt;shiny
SVG graphics&lt;/a&gt; (they are currently broken on their main website, hence the
waybackmachine link).&lt;/p&gt;


&lt;p&gt;There's already an &lt;a href=&quot;http://github.com/moritz/tufte/&quot;&gt;initial
version Perl 6 port called &quot;tufte&quot;&lt;/a&gt;, but it's not running yet. It needs your
help. If you know a little ruby, and want to learn some more Perl 6, join
#perl6, ask for a commit bit, and translate some ruby code into Perl 6. And in
the end you'll be rewarded with nice SVG charts :-).&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/contribute-now-argfiles.html">
 <title>This Week's Contribution to Perl 6 Week 8: Implement $*ARGFILES for Rakudo</title>
  <link>http://perlgeek.de/blog-en/perl-6/contribute-now-argfiles.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Tue, Jun 29 00:00:00 2010</pubDate>
    <description>&lt;!-- 1277762400 --&gt;

&lt;p&gt;For this week's contribution to Perl 6 we ask you to implement the
&lt;code&gt;$*ARGFILES&lt;/code&gt; special variable (and underlying object) for
Rakudo.&lt;/p&gt;

&lt;p&gt;(&lt;a
    href=&quot;http://perlgeek.de/blog-en/perl-6/contribute-now-announce.html&quot;&gt;Introduction
    to this series of challenges&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;Background&lt;/h2&gt;

&lt;p&gt;In Perl 5, there is a &quot;magic&quot; way to iterate over input: &lt;code&gt;while (my
$line = &amp;lt;&amp;gt;) { ... }&lt;/code&gt;. This reads from standard input if no command
line arguments were provided. If there are command line arguments, they are
taken as file names, and &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; iterates over the contents of
these files.&lt;/p&gt;

&lt;p&gt;In Perl 6 this magic is performed with the &lt;code&gt;$*ARGFILES&lt;/code&gt; special
variable. Please implement it!&lt;/p&gt;

&lt;p&gt;To do that, you have to understand how file reading works in Perl 6. Once
you have a file handle, there are two ways to read lines: either by calling
&lt;code&gt;$handle.get&lt;/code&gt;, which returns just one line, or by calling
&lt;code&gt;$handle.lines&lt;/code&gt;, which returns a (lazy) list of all the remaining
lines.&lt;/p&gt;

&lt;p&gt;You can obtain the command line arguments from &lt;code&gt;@*ARGS&lt;/code&gt;, open a
file with &lt;code&gt;my $handle = open $filename;&lt;/code&gt; for reading; And finally
you can use &lt;code&gt;lines('filename')&lt;/code&gt; to read all lines from a file.&lt;/p&gt;


&lt;h2&gt;What you can do&lt;/h2&gt;

&lt;p&gt;Implement a backend class for &lt;code&gt;$*ARGFILES&lt;/code&gt;. You can do that in
normal Perl 6 code, no need to change the actual compiler. Once that's done,
we will plug it into Rakudo. Your code might look like this:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;class&lt;/span&gt; IO::ArgFiles {
    &lt;span class=&quot;synSpecial&quot;&gt;has&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;filenames&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;synStatement&quot;&gt;method&lt;/span&gt; get() { &lt;span class=&quot;synStatement&quot;&gt;...&lt;/span&gt; }
    &lt;span class=&quot;synStatement&quot;&gt;method&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;lines&lt;/span&gt;() { &lt;span class=&quot;synStatement&quot;&gt;...&lt;/span&gt; }
    &lt;span class=&quot;synStatement&quot;&gt;method&lt;/span&gt; filename() {
        &lt;span class=&quot;synComment&quot;&gt;# return the current filename, or '-' if standard input&lt;/span&gt;
        &lt;span class=&quot;synStatement&quot;&gt;...&lt;/span&gt;
    }
}
&lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;ARGFILES&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; IO::ArgFiles&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;new&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;filenames&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;ARGS&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;ARGFILES&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;lines&lt;/span&gt;()&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;(Of course this is only a rough skeleton, you might need to change some
details, or add some things).&lt;/p&gt;

&lt;h2&gt;Submission&lt;/h2&gt;

&lt;p&gt;Please submit your source code to the &lt;a
href=&quot;mailto:perl6-compiler@perl.org&quot;&gt;perl6-compiler@perl.org&lt;/a&gt; mailing
list (and put moritz@faui2k3.org on CC,
because the mailing list sometimes lack quite a bit).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;: there have been two submissions, and a mixture of
both has been applied.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/contribute-now-lottery.html">
 <title>This Week's Contribution to Perl 6 - Lottery Intermission</title>
  <link>http://perlgeek.de/blog-en/perl-6/contribute-now-lottery.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Mon, Jun 28 23:29:11 2010</pubDate>
    <description>&lt;!-- 1277760551 --&gt;

&lt;p&gt;In the &lt;a
href=&quot;http://perlgeek.de/blog-en/perl-6/contribute-now-announce.html&quot;&gt;original
&quot;Contribute now&quot; announcement&lt;/a&gt; I've promised that there would be some
t-shirts to win.&lt;/p&gt;

&lt;p&gt;Since then there have seven challenges (mostly weekly), and I've decided on
the rules of the lottery:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Every contributor can win at most one t-shirt, even if he had
    submissions for multiple weeks&lt;/li&gt;
    &lt;li&gt;The lottery will be done on a per-week base&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of course the lottery was conducted by a Perl 6 script. Here it is:&lt;/p&gt;

&lt;pre&gt; 
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@contribs&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt;
    [ &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;patrickas&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;shawjef3@&amp;lt;omitted&amp;gt;&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Dagur Valberg Johannsson&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Juan José 'Peco' San Martín&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;]&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    [ &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;bubaflub&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt; ]&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    [ &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;patrickas&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;David Green&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt; ]&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    [ &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Hongwn Qiu&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;]&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    [ &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;David Green&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Chris Fields&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;rgrau&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;]&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    [ &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;sahadev&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Dean Serenevy&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;]&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    [ &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;cygx&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt; ]&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;%winners&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;synStatement&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@contribs&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pairs&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;(&lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt;) &lt;span class=&quot;synStatement&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$p&lt;/span&gt; {
    &lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$week&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$p&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;key&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@people&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$p&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;flat&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;grep&lt;/span&gt;({ &lt;span class=&quot;synStatement&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;%winners&lt;/span&gt;{&lt;span class=&quot;synIdentifier&quot;&gt;$_&lt;/span&gt;} })&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Candidates for Week &lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;$week&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;@people&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;join&lt;/span&gt;(&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;)&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;;&lt;/span&gt;
    &lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$winner&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@people&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;And the winner is... &lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;$winner&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;synIdentifier&quot;&gt;%winners&lt;/span&gt;{&lt;span class=&quot;synIdentifier&quot;&gt;$winner&lt;/span&gt;} &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$week&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
}

&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;%winners&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;perl&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;And then, in the moment of truth, it produced this output:&lt;/p&gt;

&lt;pre&gt;
Candidates for Week 7: cygx
And the winner is... cygx!
Candidates for Week 2: bubaflub
And the winner is... bubaflub!
Candidates for Week 5: David Green, Chris Fields, rgrau
And the winner is... David Green!
Candidates for Week 1: patrickas, shawjef3@&amp;lt;omitted&amp;gt;, Dagur Valberg Johannsson, Juan José 'Peco' San Martín
And the winner is... shawjef3@&amp;lt;omitted&amp;gt;!
Candidates for Week 4: Hongwn Qiu
And the winner is... Hongwn Qiu!
Candidates for Week 3: patrickas
And the winner is... patrickas!
Candidates for Week 6: sahadev, Dean Serenevy
And the winner is... sahadev!
{&amp;quot;Hongwn Qiu&amp;quot; =&amp;gt; 4, &amp;quot;patrickas&amp;quot; =&amp;gt; 3, &amp;quot;bubaflub&amp;quot; =&amp;gt; 2, &amp;quot;David Green&amp;quot; =&amp;gt; 5,
&amp;quot;cygx&amp;quot; =&amp;gt; 7, &amp;quot;sahadev&amp;quot; =&amp;gt; 6, &amp;quot;shawjef3\@&amp;lt;omitted&amp;gt;&amp;quot; =&amp;gt; 1}
&lt;/pre&gt;

&lt;p&gt;If you are one of the winners, and haven't told me your address yet, please
do so. Also tell me your t-shirt size, and whether you want a &lt;a
href=&quot;http://rakudo.spreadshirt.de/rakudo-perl-A10548545/customize/color/1&quot;&gt;Rakudo&lt;/a&gt; or a &lt;a href=&quot;http://rakudo.spreadshirt.de/second-system-camelia-A10548459/customize/color/1&quot;&gt;Perl 6&lt;/a&gt; t-shirt.&lt;/p&gt;

&lt;p&gt;I'd like to thank again everybody who contributed, and &lt;a
    href=&quot;http://perlfoundation.org/&quot;&gt;The Perl Foundation&lt;/a&gt; for sponsoring
some of the t-shirts!&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/contribute-now-try.rakudo.org.html">
 <title>This Week's Contribution to Perl 6 Week 7: Implement try.rakudo.org</title>
  <link>http://perlgeek.de/blog-en/perl-6/contribute-now-try.rakudo.org.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Mon, Jun 21 09:00:00 2010</pubDate>
    <description>&lt;!-- 1277103600 --&gt;

&lt;p&gt;For this week's contribution to Perl 6 we ask you to write 
a web shell for Rakudo, just like &lt;a
href=&quot;http://tryruby.org/&quot;&gt;tryruby.org&lt;/a&gt; (or &lt;a
href=&quot;http://ejohn.org/apps/learn/#1&quot;&gt;this js course&lt;/a&gt;) but for Perl 6 + Rakudo.&lt;/p&gt;

&lt;p&gt;(&lt;a
    href=&quot;http://perlgeek.de/blog-en/perl-6/contribute-now-announce.html&quot;&gt;Introduction
    to this series of challenges&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;Background&lt;/h2&gt;

&lt;p&gt;We want a website like tryruby, but for Perl 6: A combination of web shell
and built-in tutorial.&lt;/p&gt;

&lt;p&gt;The idea is that for each session a supervisor/controller process runs on
the server, which talks to a Rakudo process, and listens at a local socket.
A CGI script receives the program lines to be executed, looks up the port
number in a session file or database, and connects via a local socket to the
controller process.&lt;/p&gt;

&lt;img src=&quot;http://perlgeek.de/images/blog/tryrakudo.svg&quot; width=&quot;677&quot;
height=&quot;673&quot; alt=&quot;planned architecture of try.rakudo.org&quot; /&gt;

&lt;h2&gt;What you can do&lt;/h2&gt;

&lt;p&gt;You can help to make try.rakudo.org come real. This week I ask you to work
on the front end, ie. a HTML page with some javascript that works like a
shell; it sends the command entered by the user to a CGI script, and displays
its response.&lt;/p&gt;

&lt;p&gt;It should also be able to show instructions, and advance to the next
instruction when the user has entered what he should.&lt;/p&gt;

&lt;h2&gt;Submission&lt;/h2&gt;

&lt;p&gt;A stub of the source code can be found &lt;a
href=&quot;http://github.com/moritz/try.rakudo.org/&quot;&gt;on github&lt;/a&gt;. Please join &lt;a
href=&quot;http://perl6.org/community/irc&quot;&gt;our IRC channel&lt;/a&gt; and ask for commit
access to that repository.&lt;/p&gt;

&lt;p&gt;Then fill in any parts you want, primarily concerning the front-end. If you
have any questions, don't hesitate to ask either on the IRC channel, or on the
perl6-compiler@perl.org mailing list (and put moritz@faui2k3.org on CC,
because the mailing list sometimes lack quite a bit).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: We now have a frontend and parts of the backend,
by courtesy of cygx++. If you want to join the project, please improve what we
have now instead of submitting a new solution.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/physical-modelling.html">
 <title>Physical modeling with Math::Model and Perl 6</title>
  <link>http://perlgeek.de/blog-en/perl-6/physical-modelling.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Sun, Jun 20 13:50:01 2010</pubDate>
    <description>&lt;!-- 1277034601 --&gt;

&lt;p&gt;Let's talk about physics. I'm a physicist by education and profession, so
it might be not be too surprising. But I also want to talk about programming,
so please bear with me.&lt;/p&gt;

&lt;p&gt;When physicists try to understand a system, typically they first come up
with a lot of equations, and then try to solve them. Unfortunately some of
those equations are quite hard to solve. I've written a module that solves
them numerically, and allows you to express the equations in very simple Perl
6 code.&lt;/p&gt;

&lt;h2&gt;Getting started&lt;/h2&gt;

&lt;p&gt;Let's start with a very simple model. As a prerequisite you need the &lt;a
href=&quot;http://rakudo.org/&quot;&gt;Rakudo Perl 6 compiler&lt;/a&gt; (latest release or
current development version), and then use &lt;a
href=&quot;http://modules.perl6.org/&quot;&gt;proto&lt;/a&gt; to &lt;code&gt;proto install Math-Model&lt;/code&gt;
(which also installs its dependencies).&lt;/p&gt;

&lt;h2&gt;A first model: throwing a stone horizontally into the air&lt;/h2&gt;

&lt;p&gt;Let's start with an example (to be found in examples/vertical-throw.pl in
the Math-Model repository, with small modifications to unconfuse the syntax
hilighter used for this page).&lt;/p&gt;

&lt;p&gt;It describes the path of stone thrown vertically into the air.&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; Math::Model&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$m&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; Math::Model&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;new&lt;/span&gt;(
    &lt;span class=&quot;synConstant&quot;&gt;derivatives&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; {
        &lt;span class=&quot;synConstant&quot;&gt;y_velocity&lt;/span&gt;      &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;synConstant&quot;&gt;y_acceleration&lt;/span&gt;  &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;y_velocity&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;synConstant&quot;&gt;variables&lt;/span&gt;   &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; {
        &lt;span class=&quot;synConstant&quot;&gt;y_acceleration&lt;/span&gt;  &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; { &lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;force&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;mass&lt;/span&gt; }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;synConstant&quot;&gt;mass&lt;/span&gt;            &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; { &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt; }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;           &lt;span class=&quot;synComment&quot;&gt;# kg&lt;/span&gt;
        &lt;span class=&quot;synConstant&quot;&gt;force&lt;/span&gt;           &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; { &lt;span class=&quot;synStatement&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;9.81&lt;/span&gt; }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;       &lt;span class=&quot;synComment&quot;&gt;# N = kg m / s**2&lt;/span&gt;
    }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;synConstant&quot;&gt;initials&lt;/span&gt;    &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; {
        &lt;span class=&quot;synConstant&quot;&gt;y&lt;/span&gt;               &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;               &lt;span class=&quot;synComment&quot;&gt;# m&lt;/span&gt;
        &lt;span class=&quot;synConstant&quot;&gt;y_velocity&lt;/span&gt;      &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;              &lt;span class=&quot;synComment&quot;&gt;# m/s&lt;/span&gt;
    }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;synConstant&quot;&gt;captures&lt;/span&gt;    &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; (&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;y_velocity&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;synIdentifier&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;integrate(&lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;from&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;to&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;4.2&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;min-resolution&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;0.2&lt;/span&gt;))&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;render-svg(&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;throw-vertically.svg&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;title&lt;/span&gt;(&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;vertical throwing&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;))&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;First we declare that we use Perl 6 (&lt;code&gt;use v6;&lt;/code&gt;), and then we
load the module that does all the hard work, &lt;a
    href=&quot;http://github.com/moritz/Math-Model/&quot;&gt;Math::Model&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Then comes the interesting part: the actual model. It starts by declaring
that the derivative of &lt;code&gt;y&lt;/code&gt; (which is the name we use for the
current height of the stone) is called &lt;code&gt;y_velocity&lt;/code&gt;. Likewise the
derivative of &lt;code&gt;y_velocity&lt;/code&gt; is called
&lt;code&gt;y_acceleration&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A derivative describes the rate of change of some other variables. Here is
a short list of useful physical quantities and their derivatives:&lt;/p&gt;

&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;Quantity&lt;/th&gt;&lt;th&gt;Derivative&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;position&lt;/td&gt;&lt;td&gt;velocity&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;velocity&lt;/td&gt;&lt;td&gt;acceleration&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;acceleration&lt;/td&gt;&lt;td&gt;jerk&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;momentum&lt;/td&gt;&lt;td&gt;force&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;energy&lt;/td&gt;&lt;td&gt;power&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;charge&lt;/td&gt;&lt;td&gt;current&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;Next in the model are formulas for some variables. We don't need to give
formulas for those values on the right-hand side of the derivatives
declarations (&lt;code&gt;y&lt;/code&gt; and &lt;code&gt;y_velocity&lt;/code&gt;), which we will call
&lt;em&gt;integration variables&lt;/em&gt;. We just need formulas for the derivatives that
are not also integration variables, and for other variables we use in the
formulas.&lt;/p&gt;

&lt;p&gt;You might remember from physics class that F = m * a, force is mass times
acceleration. We use this formula for calculating the acceleration&lt;/p&gt;

&lt;pre&gt;
        y_acceleration  =&amp;gt; { $:force / $:mass },
&lt;/pre&gt;

&lt;p&gt;The other variables are actually constants (but Math::Model doesn't
distinguish those); mass is set to 1 kg, and the force to the -9.81 N that a
mass of 1 kg experiences at the latitude where I live (Germany).&lt;/p&gt;

&lt;p&gt;The programmer in you might ask what the heck the : in &lt;code&gt;$:force&lt;/code&gt;
means. It's a variable that is automatically a named parameter to the current
block. Math::Model uses &lt;a
href=&quot;http://perlcabal.org/syn/S06.html#Signature_Introspection&quot;&gt;Signature
introspection&lt;/a&gt; to find out which variables such a block depends on, and
topologically sorts all variables into an order of execution that satisfies
all the dependencies.&lt;/p&gt;

&lt;p&gt;Back to the physical model; all integration variables need an initial
value, which are provided on the next few lines. The line&lt;/p&gt;

&lt;pre&gt;
    captures    =&amp;gt; ('y', 'y_velocity'),
&lt;/pre&gt;

&lt;p&gt;tells Math::Model which variables to record while the simulation is
running.&lt;/p&gt;


&lt;pre&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;integrate(&lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;from&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;to&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;4.2&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;min-resolution&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;0.2&lt;/span&gt;))&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;render-svg(&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;throw-vertically.svg&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;title&lt;/span&gt;(&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;vertical throwing&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;))&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;Finally these two lines are responsible for running the actual simulation
(for the time t = 0s to t = 4.2s), and then write the resulting curves into
the file &lt;code&gt;throw-vertically.svg&lt;/code&gt;. And here it is, without further
ado:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://perlgeek.de/images/blog/throw-vertically.svg&quot;&gt;
&lt;img src=&quot;http://perlgeek.de/images/blog/throw-vertically.png&quot; width=&quot;526&quot;
height=&quot;353&quot; alt=&quot;integration of vertical throw&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The blue line is the height (in meter), and the yellow line the velocity
(in meter/second). Positive velocities mean that the stone is moving upwards,
negative that it's moving downwards. After about 4 seconds the stone has the
height with which it started, at a velocity of about -20m/s. You don't see any
effect of the stone hitting the ground, because the model knows nothing about
a ground located at a height of 0m. Just imagine the stone fell into a well or
down a cliff, and thus can have negative height too.&lt;/p&gt;

&lt;h2&gt;Iterating: throwing a stone at an arbitrary angle&lt;/h2&gt;

&lt;p&gt;It gets a bit more involved when you consider not only the y direction, but
also the x direction, and throw the stone at an arbitrary angle. Still the
x and y axis are rather independent:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; Math::Model&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;synStatement&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;45&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;60&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$angle&lt;/span&gt; {

    &lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$m&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; Math::Model&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;new&lt;/span&gt;(
        &lt;span class=&quot;synConstant&quot;&gt;derivatives&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; {
            &lt;span class=&quot;synConstant&quot;&gt;y_velocity&lt;/span&gt;      &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;synConstant&quot;&gt;y_acceleration&lt;/span&gt;  &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;y_velocity&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;synConstant&quot;&gt;x_velocity&lt;/span&gt;      &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
        }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;synConstant&quot;&gt;variables&lt;/span&gt;   &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; {
            &lt;span class=&quot;synConstant&quot;&gt;y_acceleration&lt;/span&gt;  &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; { &lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;force&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;mass&lt;/span&gt; }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;synConstant&quot;&gt;mass&lt;/span&gt;            &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; { &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt; }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;           &lt;span class=&quot;synComment&quot;&gt;# kg&lt;/span&gt;
            &lt;span class=&quot;synConstant&quot;&gt;force&lt;/span&gt;           &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; { &lt;span class=&quot;synStatement&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;9.81&lt;/span&gt; }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;       &lt;span class=&quot;synComment&quot;&gt;# N = kg m / s**2&lt;/span&gt;
            &lt;span class=&quot;synConstant&quot;&gt;x_velocity&lt;/span&gt;      &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; { &lt;span class=&quot;synConstant&quot;&gt;20&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;cos&lt;/span&gt;(&lt;span class=&quot;synIdentifier&quot;&gt;$angle&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; Degrees) } &lt;span class=&quot;synComment&quot;&gt;# m / s&lt;/span&gt;
        }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;synConstant&quot;&gt;initials&lt;/span&gt;    &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; {
            &lt;span class=&quot;synConstant&quot;&gt;y&lt;/span&gt;               &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;               &lt;span class=&quot;synComment&quot;&gt;# m&lt;/span&gt;
            &lt;span class=&quot;synConstant&quot;&gt;y_velocity&lt;/span&gt;      &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;20&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;sin&lt;/span&gt;(&lt;span class=&quot;synIdentifier&quot;&gt;$angle&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; Degrees)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;    &lt;span class=&quot;synComment&quot;&gt;# m/s&lt;/span&gt;
            &lt;span class=&quot;synConstant&quot;&gt;x&lt;/span&gt;               &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;               &lt;span class=&quot;synComment&quot;&gt;# m&lt;/span&gt;
        }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;synConstant&quot;&gt;captures&lt;/span&gt;    &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;y x&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    )&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;synIdentifier&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;integrate(&lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;from&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;to&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;20&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;sin&lt;/span&gt;(&lt;span class=&quot;synIdentifier&quot;&gt;$angle&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; Degrees) &lt;span class=&quot;synStatement&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;9.81&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;min-resolution&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;0.2&lt;/span&gt;))&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;synIdentifier&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;render-svg(&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;throw-angle-&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;$angle&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;.svg&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;x-axis&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;width&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;300&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;height&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;200&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;title&lt;/span&gt;(&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Throwing at &lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;$angle&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt; degreees&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;))&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
}
&lt;/pre&gt;

&lt;p&gt;The x velocity stays approximately constant (we disregard air drag), and
it's value is the cosine of the throwing angle times the initial, total
velocity. The velocity in y direction is the sine of the throwing angle times
the initial, total velocity.&lt;/p&gt;

&lt;p&gt;As a trick to get nicer graphs in the end, I calculated the expected time
until it hits the ground (which I know to be &lt;code&gt;2 * v_y / a&lt;/code&gt;; this is
cheating, but it doesn't change the physics behind it).&lt;/p&gt;

&lt;p&gt;Finally this time we don't want to have the elapsed time on the x axis, but
the actual position in x direction. That can be done with the
&lt;code&gt;:x-axis&amp;lt;x&amp;gt;&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;http://perlgeek.de/images/blog/throw-angle-30.svg&quot;&gt;
&lt;img src=&quot;http://perlgeek.de/images/blog/throw-angle-30.png&quot; width=&quot;300&quot;
height=&quot;200&quot; alt=&quot;integration of throw at 30 degrees&quot; /&gt;&lt;/a&gt;&lt;br /&gt;

&lt;a href=&quot;http://perlgeek.de/images/blog/throw-angle-45.svg&quot;&gt;
&lt;img src=&quot;http://perlgeek.de/images/blog/throw-angle-45.png&quot; width=&quot;300&quot;
height=&quot;200&quot; alt=&quot;integration of throw at 45 degrees&quot; /&gt;&lt;/a&gt;&lt;br /&gt;

&lt;a href=&quot;http://perlgeek.de/images/blog/throw-angle-60.svg&quot;&gt;
&lt;img src=&quot;http://perlgeek.de/images/blog/throw-angle-60.png&quot; width=&quot;300&quot;
height=&quot;200&quot; alt=&quot;integration of throw at 60 degrees&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;(Note that I cheated to produces these charts; normally SVG::Plot, the
module that produces these graphs, automatically scales the axis; I've
manually suppressed that; if you try to out the example you'll see that the
three charts look much the same, except for different axis scaling).&lt;/p&gt;

&lt;p&gt;The maximum
reach in x direction before hitting the ground is achieved at 45 degrees. For
smaller angles it's not long enough in the air, and for larger angles too much
of the velocity is &quot;wasted&quot; in the vertical direction, so the stone doesn't
get very far.&lt;/p&gt;

&lt;h2&gt;A third model: oscillating spring&lt;/h2&gt;

&lt;p&gt;Finally I want to present a third, simple model: a mass hanging down from a
spring, this time including air drag. It doesn't show off any new features of
Math::Model, but the result is a nice, oscillating curve.&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; Math::Model&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$m&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; Math::Model&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;new&lt;/span&gt;(
    &lt;span class=&quot;synConstant&quot;&gt;derivatives&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; {
        &lt;span class=&quot;synConstant&quot;&gt;velocity&lt;/span&gt;     &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;synConstant&quot;&gt;acceleration&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;velocity&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;synConstant&quot;&gt;variables&lt;/span&gt;   &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; {
        &lt;span class=&quot;synConstant&quot;&gt;acceleration&lt;/span&gt;    &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; { &lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;force&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;mass&lt;/span&gt; }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;synConstant&quot;&gt;mass&lt;/span&gt;            &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; { &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt; }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;synConstant&quot;&gt;force&lt;/span&gt;           &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; { &lt;span class=&quot;synStatement&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;height&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;0.2&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;velocity&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;abs&lt;/span&gt;(&lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;velocity&lt;/span&gt;)}&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;synConstant&quot;&gt;initials&lt;/span&gt;    &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; {
        &lt;span class=&quot;synConstant&quot;&gt;height&lt;/span&gt;      &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;synConstant&quot;&gt;velocity&lt;/span&gt;    &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    }&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;synConstant&quot;&gt;captures&lt;/span&gt;    &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt;
)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;synIdentifier&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;integrate(&lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;from&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;to&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;20&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;min-resolution&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;))&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;render-svg(&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;spring.svg&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;title&lt;/span&gt;(&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Spring with damping&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;))&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;The air drag/damping is built into the formula for the force. It is
proportional to the square of the velocity (making analytical solutions a
nuisance), and always points in the opposite direction as the velocity.&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;http://perlgeek.de/images/blog/spring.svg&quot;&gt;
&lt;img src=&quot;http://perlgeek.de/images/blog/spring.png&quot; width=&quot;800&quot;
height=&quot;600&quot; alt=&quot;oscillation of a spring with air drag&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Moving on&lt;/h2&gt;

&lt;p&gt;If you want to have some fun with Math::Model, here's a nice idea: You can
simulate a mass attached to a spring, which can move freely in the xy plane.
If you chose random initial values for the velocities in both directions, you
can get non-periodic (chaotic?) trajectories in the xy plane.&lt;/p&gt;

&lt;p&gt;(If you do, please send me the model so that I can also play with it :-))
&lt;/p&gt;

&lt;h2&gt;A personal note&lt;/h2&gt;

&lt;p&gt;Ever since I've used the simulation tool &quot;stella&quot; in school (must have been
year 2002 or so), I've wanted to write something similar. Math::Model is it.
It was quite fun to implement in Perl 6. The only drawback is that it's quite
slow.&lt;/p&gt;


</description>
  </item>
 
</rdf:RDF>