| Thanks for the reply, Sam. To provide some small examples, I often use Perl, and it gives me some syntax that saves me typing, such as: * `my @other_list = @a_list[3, 1, 4]` to return just those items from a list (item 3, item 1, and item 4) * `$str =~ s/$foo/BAR/g` to do string replacements (in string $str, replace all ocurrences of contents of variable $foo with "BAR") * `my $thing = $colored_objects{red}->[2]` to get item 2 in the list of red-colored objects ($colored_objects is a mapping of color names to lists of items of that color) * `my $error_msg = "Sorry, but $thing1 doesn't work with $thing2."` to interpolate the values of those 2 variables into the string * `for (reverse(1 .. 10)) { say "Counting down: $_"; }` (counts down from 10 to 1) I suppose I've always just guessed that operations like those in a Lisp language would require multiple lines and procedure calls, which would become tedious to write after a while. Is that the case? |
Here are the Clojure equivalents, omitting the act of assigning stuff to variables.
If you took the first example and assigned it to a variable other-list, it would typically be in a let expression, with a body.