Changeset 40095 in project


Ignore:
Timestamp:
05/13/21 19:18:45 (6 weeks ago)
Author:
Idiomdrottning
Message:

Adding real-life example

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/strse

    r40090 r40095  
    6161        "tiger" (then (print "I saw a cat!")))
    6262
    63 I saw a hippo!
     63I saw a hippo!br⇒ "hippopotamus"
    6464
    65 â‡’ "hippopotamus"
     65Another example:
     66
     67 (define (acc)
     68   (let ((things '()))
     69     (lambda thing
     70       (if (null? thing)
     71       things
     72       (push! (car thing) things)))))
     73 
     74 (define (extract str)
     75   (define digs (acc))
     76   (define words (acc))
     77   (strse str
     78      (= 3 num) (then (digs (string->number (m 0))))
     79      (+ alpha) (then (words (m 0))))
     80   (list (digs) (words)))
     81 
     82 (extract "it will get 234 and 123 and 747 but not 1983 or 42 but then again 420")
     83
     84⇒ ((420 198 747 123 234) ("again" "then" "but" "or" "not" "but" "and" "and" "get" "will" "it"))
    6685
    6786
     
    127146        "o" (begin (print "Found o") "i") #f)
    128147
    129 Found a
    130 
    131 â‡’ #f
     148Found abr⇒ #f
    132149
    133150A zero means to replace the entire string, not just the matched part,
Note: See TracChangeset for help on using the changeset viewer.