/* Reversing a string of words in Picat. From "Five Ways to Reverse a String of Words" http://www.perlmonks.org/?node_id=589260 """ Recently, the C# programmers at work have been asking job applicants to write a function to reverse a string of words. For example, given an input string of: " one two three four " the function should produce: "four three two one" """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import util. main => go. go => " one two three four ".strip().split().reverse().join(' ').println(), % one don't have to use strip() " one two three four ".split().reverse().join(" ").println(), % without join(' ') it's a list of words " one two three four ".split().reverse().println(), % using writeln/1 instead of println/1 is not that nice looking " one two three four ".split().reverse().join(' ').writeln(), nl.