Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * Find Forwards. Starting at the current cursor position, locate the next
- *
- * occurrence of the character c. If the cursor reaches the end of the string
- *
- * without finding an occurrence of c then return false and return leave the
- *
- * cursor position unchanged. If the cursor finds an occurrence of c then leave
- *
- * the cursor at that position and return true.
- *
- * This operation does not change any variable other than the cursor position.
- *
- * Example:
- *
- * m i s s i s s i p p i
- *
- * ^ cursor = 0
- *
- *
- *
- * Then perform ff('i')
- *
- *
- *
- * m i s s i s s i p p i
- *
- * ^ cursor = 1: returns true
- *
- *
- *
- * Then perform ff('i')
- *
- *
- *
- * m i s s i s s i p p i
- *
- * ^ cursor = 1: returns true
- *
- *
- *
- * Then perform ff('p')
- *
- *
- *
- * m i s s i s s i p p i
- *
- * ^ cursor = 8: returns true
- *
- *
- *
- * Then perform ff('s')
- *
- *
- *
- * m i s s i s s i p p i
- *
- * ^ cursor = 0: returns false
- *
- */
- def ff( c: Char ): Boolean = {
- var a = false
- ( cursor until end ) collectFirst { case i if buffer( i ) == c => cursor = i; a = true }
- a
- }
- /* var b = false
- ( cursor until end )
- .withFilter( x => !b )
- .withFilter( x => buffer( x ) == c )
- .foreach( x => {
- b = true
- cursor = x
- } )
- b */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement