I'm trying to port some Python code to Clojure. I'm new to functional programming and I hit a function that is causing my brain to melt. The python function looks something like this:
def build_table(): num_cols = 3 selected_row = 0 selected_col = 0 strings = ["cat", "dog", "", "rabbit", "frog", "elephant", "gorilla"] row, col = 0, 0 table_contents = "<table cellpadding=30 bgcolor=#6666aa>\n<tr>\n" for string in strings: if string == "": continue if col >= num_cols: row += 1 col = 0 table_contents += "</tr>\n<tr>" def new_cell(): bg_color = "cfcfdf" if(col == selected_col and row == selected_row): bg_color = "d0e0ff" return "<td bgcolor=#" + bg_color + ">" + \ "<font color=#0000cc>" + string[0] + \ "</font>" + string[1:] + "</td>\n" table_contents += new_cell() col += 1 table_contents += "</tr>\n</table>" return table_contents If someone could please demonstrate how to do this in Clojure, I think it would greatly help my understanding of the language and functional programming in general. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---