[squeak-dev] Anybody got an elegent construct for this        functional monstrosity?

gettimothy gettimothy at zoho.com
Wed Dec 1 13:14:25 UTC 2021


Here is a stab of Eliot's approach...





Oops.  I meant of course

| patterns first second Firsts Seconds |
patterns :=  #('{|' '|-' '|}' '{{' '}}' '[[' ']]' '__' '==' '::' '**' '##' '''').
Firsts ifNil:
   [Firsts := ((patterns collect: #first) as: Set) as: String.
    Seconds  := ((patterns collect: #second) as: Set) as: String].
self size >= 2
and: [(Firsts includes: (first := self first))
and: [(Seconds includes: (second := sef second)
and: [patterns includes: (ByteString with: first with: second)]]]








 adapted towards a workspace.





| ios patterns firsts seconds|

ios := ReadStream on: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...|-'.

patterns :=  #('{|' '|-' '|}' '{{' '}}' '[[' ']]' '__' '==' '::' '**' '##' '''''').

firsts := ((patterns collect: #first) as: Set).

seconds  := ((patterns collect: #second) as: Set).

[(ios size >= 2) & (ios peek notNil) ]

      whileTrue:[

            ((firsts includes: (first := ios next))

              and: [(seconds includes: (second := ios peek))]

              and: [patterns includes: (ByteString with: first with: second)])

                        ifTrue:[^true]]


cordially
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211201/a4488ddf/attachment.html>


More information about the Squeak-dev mailing list