Sha256: 845dd92452bb5d18f46b1916af58ff8516ae14c87ded6928d20dee1f4aa15242

Contents?: true

Size: 939 Bytes

Versions: 13

Compression:

Stored size: 939 Bytes

Contents

param $MAX := 10

Rule Main
  output '*.prime'.all
Flow
  rule CreateUndeterminedNumbers >>> Sieve
End

Rule CreateUndeterminedNumbers
  output '*.ud'.all
  param $N := 2.upto($MAX)
Flow
  rule CreateData {NAME: "{$N}.ud"}
End

Rule Sieve
  input '*.ud'.all or null
  input '*.prime'.all or null
  output '*.prime'.all.neglect
  output 'finished'
  param $N := 2
Flow
  if $*.as_data_expr.match?($N.str)
    if ($N * $N) <= $MAX
      rule CreateData {NAME: "{$N}.prime"} >>> RemoveUndeterminedNumber >>> Sieve {N: $N+1}
    else
      rule UndeterminedNumber2Prime
      rule CreateData {NAME: "finished"}
    end
  else
    rule Sieve {N: $N+1}
  end
End

Rule RemoveUndeterminedNumber
  input '*.prime'
  input '*.ud'
  output '{$I[2][1]}.ud'.remove
  constraint ($I[2][1].i % $I[1][1].i) == 0
End

Rule UndeterminedNumber2Prime
  input '*.ud'
  output '{$*}.prime'.touch
End

Rule CreateData
  param $NAME
  output '{$NAME}'.touch
End

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pione-0.5.0 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.5.0.alpha.2 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.5.0.alpha.1 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.4.2 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.4.1 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.4.0 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.3.2 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.3.1 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.3.0 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.2.2 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.2.1 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.2.0 example/SieveOfEratosthenes/SieveOfEratosthenes.pione
pione-0.1.4 example/SieveOfEratosthenes/SieveOfEratosthenes.pione