Yet another weird SF fan

I'm a mathematician, a libertarian, and a science-fiction fan. Common sense? What's that?

Go to first entry



<< current
E-mail address:
jhertzli AT ix DOT netcom DOT com

My Earthlink/Netcom Site

My Tweets

My other blogs
Small Sample Watch
XBM Graphics

The Former Four Horsemen of the Ablogalypse:
Someone who used to be sane (formerly War)
Someone who used to be serious (formerly Plague)
Rally 'round the President (formerly Famine)
Dr. Yes (formerly Death)

Interesting weblogs:
Back Off Government!
Bad Science
Boing Boing
Debunkers Discussion Forum
Deep Space Bombardment
Depleted Cranium
Dr. Boli’s Celebrated Magazine.
Foreign Dispatches
Good Math, Bad Math
Greenie Watch
The Hand Of Munger
Howard Lovy's NanoBot
Liberty's Torch
The Long View
My sister's blog
Neo Warmonger
Next Big Future
Out of Step Jew
Overcoming Bias
The Passing Parade
Peter Watts Newscrawl
Physics Geek
Pictures of Math
Poor Medical Student
Prolifeguy's take
The Raving Theist
Respectful Insolence
Seriously Science
Slate Star Codex
The Speculist
The Technoptimist
Tools of Renewal
XBM Graphics
Zoe Brain

Other interesting web sites:
Aspies For Freedom
Crank Dot Net
Day By Day
Dihydrogen Monoxide - DHMO Homepage
Jewish Pro-Life Foundation
Libertarians for Life
The Mad Revisionist
Piled Higher and Deeper
Science, Pseudoscience, and Irrationalism
Sustainability of Human Progress

Yet another weird SF fan

Thursday, December 25, 2003

XSLT and Mathematics

I've been studying XSLT lately. After I found out that it can produce factorials, I decided to devise an xsl file that could produce a hailstorm sequence:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
 <xsl:output method="text"/>
 <xsl:strip-space elements='*'/>
 <xsl:template name="hailstorm">
  <xsl:param name="n" select="1"/>
  <xsl:variable name="sequence">
   <xsl:if test="$n mod 2 = 0">
    <xsl:call-template name="hailstorm">
     <xsl:with-param name="n" select="$n div 2"/>
   <xsl:if test="($n mod 2) * ($n - 1) > 0">
    <xsl:call-template name="hailstorm">
     <xsl:with-param name="n" select="$n * 3 + 1"/>
  <xsl:value-of select="$n"/>
  <xsl:if test="$n > 1">
   <xsl:value-of select="', '"/>
  <xsl:value-of select="$sequence"/>
 <xsl:template match="number">
  <xsl:variable name="x" select="."/>
  <xsl:variable name="y">
   <xsl:call-template name="hailstorm">
    <xsl:with-param name="n" select="$x"/>
  <xsl:value-of select="'hailstorm('"/>
  <xsl:value-of select="$x"/>
  <xsl:value-of select="') = '"/>
  <xsl:value-of select="$y"/>
  <xsl:value-of select="'&#xA;'"/>
You can start by naming the above file "hailstor.xsl" and running it on the following:
<?xml version="1.0"?>
<?xml-stylesheet href="hailstor.xsl" type="text/xsl"?>


Post a Comment

<< Home

My Blogger Profile
eXTReMe Tracker X-treme Tracker

The Atom Feed This page is powered by Blogger.