What Comes To Mind
Monday, February 20, 2006
  Brew Day!
Brewer: Steve Downey
-
Beer: February Ale Style: American Amber Ale
Type: All grain Size: 5.5 gallons
Color:
13 HCU (~9 SRM)
Bitterness: 38 IBU
OG: 1.052 FG: (Est)
1.012
Alcohol: 5.2% v/v (4.1% w/w) (Estimated)
Grain: 2 lb. Weyermann Dark Wheat
10 lb. Weyermann Vienna
1 lb. Weyermann Cara Amber
Mash: 60% efficiency
Boil: 60 minutes SG 1.044 6.5 gallons
Hops: 1 oz. Cascade (5.3% AA, 60 min.)
1 oz. Cascade (5.3% AA, 30 min.)
1 oz. Cascade (5.3% AA, 5 min.)

Recipe formatting and calculations by The Beer Recipator.


Mashed with a single decoction. Doughed in with three gallons of water to 135 degrees F. Let rest for 15 minutes, then pulled a third of the thick mash and boiled for 15 minutes. Added back, and added hot liquor to reach 158 degrees F, and let rest for about an hour (during a trip to Target with the kids...)

Sparged with another 4 gallons of liquor and collected 6.5 gallons of sweet wort. Estimated efficiency, 60%. Low. Should probably investigate.

Added the first hops in while collecting the runoff.

Boiled for 60 minutes, with two hop additions at 30 minutes and at 5. Also added 1 tsp of irish moss at 15 minutes.

Collected 5.5 gallons of 1.052 wort, and pitched 20 grams of Safeale 33 yeast.

Total time, around 6 1/2 hours. Although I still have some clean up.
 

Monday, February 13, 2006
  Bill de hÓra: I think I figured out the list comprehensions thing...
Bill de hÓra: I think I figured out the list comprehensions thing...

I've been trying to understand this stuff myself, and Bill de hÓra's post has prodded me to write this down so I won't forget it again.

List comprehensions are really just syntatic sugar. And too much syntatic sugar can cause truth decay.

List comprehensions are forms in functional and related languages that allow you to generate an entire list with a description of the list. So, for example, I can get a list of the first 10 squares by:
[ x * x | x <- [1..10] ]
[1,4,9,16,25,36,49,64,81,100]

That gives me a list of the squares of x, where x is an element of the list of integers from 1 to 10. I can also add some more qualifiers, like

[ x * x | x <- [1..10], x>3]

[16,25,36,49,64,81,100]


[i * j | i<- [1..5], j <-[1..5], (i+j) > 5]
[5,8,10,9,12,15,8,12,16,20,5,10,15,20,25]

This is all pretty neat, but what does it really mean?

You 'normally' think of drawing a variable from each of the generating lists, with the right most one varying most quickly, and skipping if the variables fail to meet the condition. This provides a natural analogue to the looping constructs in most programming languages.
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
if ((i + j) > 5) {
list.push(i*j);
}
}
}

That close, natural, analogue can be a code smell in functional programming. It may be an indication that you're thinking of the problem in terms of loops, updating variables, etc.

The intent of list comprehension is to simulate loops and conditions, but it can be defined in terms of map and list concat. (As far as I can tell, this is due to P. Wadler, in Simon Peyton-Jones's The Implementation of Functional Programming Languages )


[t | x <- u] ==> map (\x -> t) u
[t | p, q] ==> concat [ [t | q] | p ]
[t | b ] ==> if (b) then [t] else []

Note that the two qualifications p and q are reversed when translated.

concat will take the results of the simplified comprehension and concatenate all of the resulting lists together, eliminating empty lists.

Lets take the first, simple, example:
[ x * x | x <- [1..10] ]
that translates to:
map (\x -> x * x) [1..10]
The next example
[ x * x | x <- [1..10], x>3]
takes a few more steps

concat [ [x * x | x> 3] | x <- [1..10] ]

concat ( map (\x -> [x * x | x>3]) [1..10] )

concat (map (\x -> (if (x>3) then [x*x] else [])) [1..10])

In this case, the list comprehension is more concise. On the other hand, the expanded version is a bit more suggestive. Particularly if I'm willing for it not to be a lambda expression.



 

Random notes and stuff

My Photo
Name: Steve Downey
Archives
September 2004 / January 2005 / February 2005 / March 2005 / May 2005 / June 2005 / October 2005 / January 2006 / February 2006 / March 2006 / January 2007 / February 2007 / April 2007 / November 2007 / December 2007 / January 2008 / September 2008 / November 2008 / April 2009 / July 2009 /


Powered by Blogger

Subscribe to
Posts [Atom]