Stanza Updates?


Yves Cloutier
 

Hi Patrick,

I'll bet a few of us keep coming to the website to see what'sthe latest happenings going on with stanza.  Would it be possible to give a little update on how things are progressing?


On another note, I'm taking a nice course on Coursera which covers ML, Racket and Ruby. I've been having some fun and trying to reproduce my homework answers in Stanza. Here's an example:

ML Version
(* Functon that takes a list of dates and a month. It returns the number of times the month specified occurs in the list of dates*)
fun number_in_month(dates: (int*int*int) list, month:int) =
  if null dates (*edge case*)
  then 0
  else
    if #2(hd(dates)) = month
    then 1 + number_in_month(tl dates, month)
    else 0 + number_in_month(tl dates, month)

Stanza Version

defstruct Date :
  year:Int
  month:Int
  day:Int

defn number-in-month (dates:List<Date>, selected-month:Int) -> Int:
  if empty?(dates) :
    0
  else :
    if month(head(dates)) == selected-month :
       1 + number-in-month(tail(dates), selected-month)
    else :
       0 + number-in-month(tail(dates), selected-month)

I wasn't sure how to specify an argument of type "list of tuples" as in the ML version, so instead I ended up creating a struct and having the type be a List<Date>.

A simple example, I know, but still...fun:)


Join lbstanza@groups.io to automatically receive all group messages.