progs/catastrophic/catastrophic.js
changeset 745 7dc3643a0cc5
parent 741 e66bd5c563eb
child 753 d94fdbef1a4f
equal deleted inserted replaced
744:99c5916d9a8f 745:7dc3643a0cc5
     1 
     1 #!/usr/local/bin/node
     2 
       
     3 
     2 
     4 // A case of catastrophic backtracking in JavaScript/Node.js
     3 // A case of catastrophic backtracking in JavaScript/Node.js
     5 //
     4 //
     6 // regex: (a*)*b
     5 // regex: (a*)*b
     7 // strings: aa...
     6 // strings: aa...
     8 //
     7 //
     9 // call with:
     8 // call with:
    10 //
     9 //
    11 //  $> node catastrophic.js 20
    10 //  $> catastrophic.js 20
    12 //
    11 //
    13 // call with timing as:
    12 // call with timing as:
    14 //
    13 //
    15 //  $> time node catastrophic.js 25
    14 //  $> time catastrophic.js 25
    16 
    15 
    17 
    16 
    18 const args = process.argv[2]
    17 const args = process.argv[2]
    19 
    18 
    20 var str = 'a'.repeat(args);
    19 var str = 'a'.repeat(args);