Linguistics 158: Computer-aided methods in linguistics
John B. Lowe /
Department of Linguistics
University of California, Berkeley - Spring 1997
Assignment 5 : HyperCard Stack
(due: Th 20 Mar , 1997)
1. Create an "anagram detector"
on mouseUp
set the hilite of me to true
put empty into KeyList
repeat with i = 1 to the number of words in cd fld "SourceText"
put SortWord(word i of cd fld "SourceText") & return after KeyList
end repeat
sort KeyList
put empty into Anagrams
repeat with i = 1 to the number of lines in KeyList
put i+1 into j
repeat while word 1 of line i of KeyList = word 1 of line j of KeyList
if not (last line of Anagrams contains word 2 of line i of KeyList) then put word 2 of line i of KeyList & space after Anagrams
add 1 to i
end repeat
if the number of words in the last line of Anagrams = 1 then delete last line of Anagrams
if last line of Anagrams is empty then delete last line of Anagrams
if i = j+1 then put return after Anagrams
put Anagrams into cd fld "Anagrams"
end repeat
set the hilite of me to false
end mouseUp
function SortWord wrd
repeat with i = 1 to the number of chars in wrd
put char i of wrd into line i of w
end repeat
sort w
put empty into result
repeat with i = 1 to the number of lines in w
put line i of w after result
end repeat
return result && wrd
end SortWord
"Answers" to homework
This document is: http://www.linguistics.berkeley.edu/Lx158/assignments/HyperCard.html
[Ling 158 Home Page |
Linguistics 158 schedule]