Haskell For Kids: Week 6

(This is from last week. Yes, I’m really late in posting this… sorry! This week’s summary will be up in a couple days.)

Practice Time

Welcome to the week 6 summary of Haskell for Kids, my middle school level (that is, ages 12 – 13 ish) programming class using Haskell and Gloss at the Little School on Vermijo. You can go back and review weeks 1, 2, 3, 4, and 5 if you like.

This week was time for practice. Instead of introducing any new ideas, I’ll just post the practice activity we did together in class on Tuesday. The way we practiced was very simple: I drew pictures, and we tried to write descriptions of those pictures. Rather than waste time, let’s just jump right into it. It might help to download (and maybe print out) the PDF file from the end of week 5 (follow the link earlier) for a reminder of how to write list comprehensions.

I’m not including answers, because it’s too easy to just read ahead! If you can’t figure one of them out, feel free to ask for help in the comments.

Practice 1

Hints: None! Hopefully this one is easy.

Practice 2

Hints: The parameter to circle is a number. Use the variable from the list comprehension for that.

Practice 3

Hints: This one should also be easy. It’s just a stepping stone to the next practice.

Practice 4

Hint: The list comprehension variable tells you how far to translate.

Practice 5

Hint: Don’t do this with rotate. You can change just one thing from practice 4 and make this work. Remember that you can use the list comprehension variable more than once.

Practice 6

Hint: Remember that if you translate something first and then rotate it, it will be rotated around the middle of the picture.

Practice 7

Hint: Here you’ll want to use two variables in your list comprehension. One of the examples from the reference page shows you how to do this.

Practice 8

Hint: Again you want two variables, but this time one of them will be used in translate and the other one in rotate.

Projects

In addition to this, we just worked on our list comprehension projects. If you remember from last week, the project was to pick something repetitive and draw it. I suggested a U.S. flag if you’re in the U.S. and don’t have another idea. Some of the other projects kids from our class came up with were an iPhone with a grid of icons, a keyboard (the musical type!), and a galaxy with spiral arms and a background of stars. So be creative!

Oh, and I have to show off Sophia’s keyboard, because she worked really, really hard on it, and I’m very impressed. It’s a great use of list comprehensions, too. Here goes…