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
quantityOfIngredient: theIngredient | |
"return the accumulated quantity of an ingredient across all recipes" | |
^ recipes inject: 0 into: [ :totalQuantity :aRecipe | | |
aRecipe ingredients inject: totalQuantity into: [ :theTotalQuantity :anIngredient | | |
( theIngredient = anIngredient ) | |
ifTrue: [ theTotalQuantity + anIngredient quantity ] | |
ifFalse: [ theTotalQuantity ] | |
] |
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
^ (integer \\ 15 = 0) ifTrue: [ 'FizzBuzz' ] ifFalse: [ | |
(integer \\ 3 = 0) ifTrue: [ 'Fizz' ] ifFalse: [ | |
(integer \\ 5 = 0) ifTrue: [ 'Buzz' ] ifFalse: [ integer ] |
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
StarMap>>renderContentOn: canvas | |
self generateStarCollection renderStarsOn: canvas. | |
StarCollection>>renderStarsOn: canvas | |
stars do: [ :aStar | aStar renderHtmlOn: canvas ]. | |
Star>>renderHtmlOn: canvas |
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
StarMap>>renderContentOn: html | |
self generateStarCollection renderStarsOn: html. | |
StarCollection>>renderStarsOn: html | |
stars do: [ :aStar | aStar renderHtmlOn: html ]. | |
Star>>renderHtmlOn: html |
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 sum of the lengths of any two sides of a triangle always exceeds the length of the third side | |
raise TriangleError if ( vertices.inject(0) { |sum,vertex| sum += vertex } - vertices.max <= vertices.max ) | |
return :equilateral if ( vertices.uniq.size == 1 ) | |
return :isosceles if ( vertices.uniq.size == 2 ) | |
return :scalene |
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
(#(#(if (pos? %2) (recur (pop %1) (dec %2)) (first %1)) (flatten %1) %2) '(4 5 6 7) 2 )) |
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
(ns jquerytest.core) | |
(def jquery (js* "$")) | |
(jquery | |
(fn [] | |
(-> (jquery "div.meat") | |
(.html "This is a test.") | |
(.append "<div>Look here!</div>")))) |
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
When I click "Edit" |
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
// Implementation of Party initializers deferring to a Designated Initializer | |
#import "Party.h" | |
@implementation Party | |
-(Party*)initWithLocation:(NSString*)location { | |
return [self initWithLocation: location date:[self defaultDate] attendees:[self defaultAttendees]]; | |
}; |
OlderNewer