comparison lib/js/urweb.js @ 829:20fe00fd81da

Substring functions; fix a nasty MonoReduce pattern match substitution bug
author Adam Chlipala <adamc@hcoop.net>
date Sat, 30 May 2009 13:29:00 -0400
parents 14a6c0971d89
children 5e1a4b12c83a
comparison
equal deleted inserted replaced
828:14a6c0971d89 829:20fe00fd81da
351 function bs(b) { return (b ? "True" : "False") } 351 function bs(b) { return (b ? "True" : "False") }
352 352
353 function sub(s, i) { return s[i]; } 353 function sub(s, i) { return s[i]; }
354 function suf(s, i) { return s.substring(i); } 354 function suf(s, i) { return s.substring(i); }
355 function slen(s) { return s.length; } 355 function slen(s) { return s.length; }
356 function sidx(s, ch) {
357 var r = s.indexOf(ch);
358 if (r == -1)
359 return null;
360 else
361 return r;
362 }
363 function schr(s, ch) {
364 var r = s.indexOf(ch);
365 if (r == -1)
366 return null;
367 else
368 return s.substring(r);
369 }
370 function ssub(s, start, len) {
371 return s.substring(start, start+len);
372 }
356 373
357 function pi(s) { 374 function pi(s) {
358 var r = parseInt(s); 375 var r = parseInt(s);
359 if (r.toString() == s) 376 if (r.toString() == s)
360 return r; 377 return r;