3 ms·
I z = (S C C) z = (C z) (C z) = C z _ = z Where _ stands for a value that doesn't matter. And actually for any x we have S C x == I.
by eru 15y ago
I z = (S C C) z = (C z) (C z) = C z _ = z
Where _ stands for a value that doesn't matter.
And actually for any x we have S C x == I.
- fexl 15y agoYes, I like that expository technique of using "_". Often when I develop a Fexl function I actually use "_" as a placeholder for "something I haven't implemented yet". So if I'm doing something with a list, I might say: list _ \head\tail _ And then I just go back and replace each "_" with an implementation of that particular case. In doing so, I might create new "_" slots ("holes"), which I then implement, and then I repeat this process until no more holes appear. It's a really good "case analysis" approach to programming. For example I used this approach to implement an associative key-value map structure which uses nested lists, where a list at level N branches on the Nth character of the key, so it's a radix-style algorithm but without splitting the keys into pieces: # Helper function. \map_put == (\map\pos\key\val map (item (pair key (pair val end)) map) \head\tail head \top_key\top_node # Do a three-way comparison of key char at pos # with the top key char at that pos. long_compare (string_at key pos) (string_at top_key pos) # key char is less than top key char (item (pair key (pair val end)) map) # key char equals top key char ( top_node \top_val\top_map \new_head = ( string_compare key top_key (pair key (pair val (map_put top_map (long_add pos 1) top_key top_val))) (pair key (pair val top_map)) (pair top_key (pair top_val (map_put top_map (long_add pos 1) key val))) ) item new_head tail ) # key char is greater than top key char (item head (map_put tail pos key val)) ) # The actual function (map_put key val). This just # calls the helper function with position 0 to start. # I should probably re-order the helper function so # pos is the last argument, then I can define this # function simply as \map_put = (map_put 0). \map_put = (\map\key\val map_put map 0 key val)
- eru 15y agoThanks! By the way, if you like SKI calculus, you would have loved this year's ICFP programming contest.