Tokenize a string: Difference between revisions

Content added Content deleted
m (→‎{{header|Haskell}}: The wiki interpreted part of the program as Wikilink, which clearly wasn't intended)
Line 327: Line 327:
=={{header|Smalltalk}}==
=={{header|Smalltalk}}==
|array |
|array |
array := ('Hello,How,Are,You,Today' findTokens: $,) asArray.
array := 'Hello,How,Are,You,Today' subStrings: $,.
array fold: [:concatenation :string | concatenation, '.', string ]
Transcript show:

(array inject: ''
Some implementations also have a ''join:'' convenience method that allows the following shorter solution:
into:

[:concatenation :string | concatenation , string , '.'])
('Hello,How,Are,You,Today' subStrings: $,) join: '.'

The solution displaying a trailing period would be:

|array |
array := 'Hello,How,Are,You,Today' subStrings: $,.
array inject: '' into: [:concatenation :string | concatenation, string, '.' ]


=={{header|Standard ML}}==
=={{header|Standard ML}}==