Select featured exercises for Summer of Sexps

Works for me :slight_smile:

1 Like

Okay, we’ll go with:

leap : boolean conditions, truthiness, possible lexical scoping due to nested helper function, good introduction to Lisp syntax
two-fer : optional values, handled differently across the tracks
difference-of-squares : math/prefix notation, ranges
robot-name : randomness, strings and potentially OO
matching-brackets : strings as lists of characters

1 Like

Are you suggesting this exercise should have the student implement map? With map? recursion? iteration?

Perhaps if you could give me an idea of what you think this exercise would look like for Common Lisp I could see the benefit.

And what level of student of Common Lisp would we need to target? Would we expect them to understand recursion or do/loop constructs?

This demands dealing with mutable state in Clojure. It needs atoms etc. Definitely not for beginners. Are you sure?

Edit: Maybe any of the following?

  • Run-Length Encoding (strings)
  • Binary Search Tree
  • Flatten Array (recursion, lazy-seq)
  • Perfect Numbers
  • Robot Simulator (maps, reduce)
  • Binary search

If i’m not mistaken, the last two were previously featured.

That’s true. The idiomatic solution doesn’t look that difficult to me, but I don’t know. @porkostomus what do you think?

robot-name would be fine. Atoms are really simple, and very important too :slight_smile:

1 Like

Great. Let’s keep robot-name then. I really like that students have to use atoms and that it shows that Lisps are not just purely functional languages.

Since we already decided on a different exercise it’s not important / doesn’t have urgency for Summer of Sexps now.

Are you suggesting this exercise should have the student implement map? With map? recursion? iteration?

The idea of the exercise is for students to not use the built-in list-ops. Otherwise it doesn’t matter how they implement it.

These are the benefits I see in this exercise:

  • good way for students to feel really comfortable using functions like map and fold/reduce is implementing them themselves, students develop a better mental model of what’s going on under the hood. especially fold often takes a while for new programmers / programmers new to FP to fully grasp.
  • students can learn that in languages with higher-order functions you can implement list iteration in terms of the primitives foldl and foldr
  • students can learn that you don’t have to implement foldl and foldr recursively in a non-pure language. it might even be the way to go in a language without tail-call elimination. (to that end I’ve included bonus tests in the Emacs Lisp track that lead to a stack overflow with a naive (tail-)recursive implementation, as Emacs Lisp doesn’t have automatic TCE, eg. the example implementation would fail those bonus tests)

For better or worse the instructions also don’t push students in the direction of using foldl and foldr as the base layers to implement all other operations, so students in theory can implement each operation with a hand-crafted loop. So they can solve it as long as they grasp higher-order functions. If they want to engage deeper they can request mentoring and/or check the community solutions. Although I also think that the exercise is a prime candidate for approaches / a dig deeper tab.

Hope this helps. Let me know if you have more questions. :)

You make a good case for it. Not sure when I’ll be getting back to adding exercises to the Common Lisp track though - but I’ll keep this one on the list.