I was just going through some old notes and found this Scala DSL example from 2010:
Here’s a little example of how to use a break in a Scala for loop:
Unix/Linux shell script FAQ: How do I write a Unix or Linux shell script where I "do something" for every line in a text file?
Solution: An easy way to process every line in a text file is to use a Unix/Linux while loop in combination with the Linux cat command, like this:
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 3.18, “How to create your own control structures in Scala.”
You want to define your own control structures to improve the Scala language, simplify your own code, or create a DSL for others to use.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 3.5, “ Scala: How to use break and continue in for loops (and while loops)”
You have a situation where you need to use a
continue construct, but Scala doesn’t have
This post contains a collection of Scala control structures examples. I initially created most of these in the process of writing the Scala Cookbook. Unlike the Cookbook, I don’t describe them much here, I just show the examples, mostly as a reference for myself (and anyone else that can benefit from them).
if/then control structures:
Here are some examples of the Scala if/then control structure:
for loop FAQ: How do I use an AppleScript
for loop? (Also, how do you use an AppleScript while loop?)
This is actually a bit of a trick question, as there is no AppleScript
for loop or
while loop syntax. Instead you use the AppleScript
repeat command, as shown in the following examples.
AppleScript for loop examples
Where you might expect an AppleScript for loop to iterate over a list, you use the AppleScript
repeat with syntax:
AppleScript list FAQ: How do I iterate/loop over an AppleScript list?
As I continue to work on my Mac speech recognition software projects, I've often found the need to loop over an AppleScript list. One way to loop over an AppleScript list is to use the AppleScript repeat with syntax: