Christopher Allen
Shared posts
11 Sep 08:52
Programming Lessons
By the beginning of summer vacations, my niece Thao was pretty comfortable programming in Blockly Games. So for the next couple of months I spent one day a week teaching her more advanced...
19 Oct 12:05
http://funcall.blogspot.com/2013/08/lets-start-with-list-b-c-d-e-f-g-h-i-j.html
by Joe Marshall
Let's start with a list:
We'll add some elements:
Delete some:
Add some more:
Maybe delete one:
We want to compare the original sequence with the end sequence and
summarize the difference with a set of "indels", which specify the
indexes at where elements were inserted or deleted:
For an extreme challenge, implement this in a way that is not hopelessly inefficient.
'(a b c d e f g h i j)
We'll add some elements:
'(a b c d e f g h i j k l m n o)
Delete some:
'(a b c d e i j k l m n o)
Add some more:
'(x y z a b c d e i j k l m n o)
Maybe delete one:
'(x y z b c d e i j k l m n o)
We want to compare the original sequence with the end sequence and
summarize the difference with a set of "indels", which specify the
indexes at where elements were inserted or deleted:
(diff '(a b c d e f g h i j) '(x y z b c d e i j k l m n o)) (#S(INDEL :LEFT-SUBSEQ-START 0 ;; 'a' :LEFT-SUBSEQ-LIMIT 1 :RIGHT-SUBSEQ-START 0 ;; 'x y z' :RIGHT-SUBSEQ-LIMIT 3) #S(INDEL :LEFT-SUBSEQ-START 5 ;; 'f g h' :LEFT-SUBSEQ-LIMIT 8 :RIGHT-SUBSEQ-START 7 ;; nothing :RIGHT-SUBSEQ-LIMIT 7) #S(INDEL :LEFT-SUBSEQ-START 10 ;; nothing :LEFT-SUBSEQ-LIMIT 10 :RIGHT-SUBSEQ-START 9 ;; 'k l m n o' :RIGHT-SUBSEQ-LIMIT 14))Exercise 6 (hard): Implement this.
For an extreme challenge, implement this in a way that is not hopelessly inefficient.
No more posts. Check out what's trending.