This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function greeter(salutation) { | |
var counter = 0; | |
var prefix = '. ' + salutation + ' '; | |
return function(name) { | |
counter++; | |
return counter + prefix + name + '!'; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void reportsLostIfAuctionClosesWhenBidding() { | |
context.checking(new Expectations() {{ | |
ignoring(auction); | |
allowing | |
(sniperListener).sniperBidding(); then(sniperState.is("bidding")); | |
atLeast(1).of | |
(sniperListener).sniperLost(); when(sniperState.is("bidding")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
quicksort :: (Ord a) => [a] -> [a] | |
quicksort [] = [] | |
quicksort (x:xs) = | |
let smallerSorted = quicksort [a | a <- xs, a <= x] | |
biggerSorted = quicksort [a | a <- xs, a > x] | |
in smallerSorted ++ [x] ++ biggerSorted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
quicksort' :: (Ord a) => [a] -> [a] | |
quicksort' [] = [] | |
quicksort' (x:xs) = | |
let smallerSorted = quicksort' (filter (<=x) xs) | |
biggerSorted = quicksort' (filter (>x) xs) | |
in smallerSorted ++ [x] ++ biggerSorted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
largestDivisible :: (Integral a) => a | |
largestDivisible = head (filter p [100000,99999..]) | |
where p x = x `mod` 3829 == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum (takeWhile (<10000) (filter odd (map (^2) [1..]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Our sample handler extends AbstractHandler, an IHandler base class. | |
* | |
* @see org.eclipse.core.commands.IHandler | |
* @see org.eclipse.core.commands.AbstractHandler | |
*/ | |
public class OrderOverviewHandler extends AbstractHandler { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The constructor. | |
*/ | |
public OrderOverviewHandler() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* the command has been executed, so extract extract the needed information from the application | |
* context. | |
*/ | |
public Object execute(ExecutionEvent event) | |
throws ExecutionException { | |
LaunchCommand orderOverviewCmd = new LaunchCommand("overviewOrderStatus"); | |
LaunchCommandParameter param = new LaunchCommandParameter(); | |
param.setLaunchMode(LaunchMode.DIALOG); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
* <p> | |
* You can create a command, you can test it and you can execute it. | |
* | |
* @author rge | |
*/ | |
public class LaunchCommand { | |
private String commandId = null; | |
private boolean bAvailable = false; |
OlderNewer