-- > is still slow, but dropping down to > > (def wlistdata (to-array (take 26 (words-with "...............")))) > > (def update-wlist #(let [w (take 26 (words-with (current-word)))] > (. words setListData wlistdata))) > > leaves everything running smoothly. Is there a more efficient way to do this? >
That doesn't actually prove that it is to-array that is the slow part. This is because all of the seq manipulation stuff that you are doing is 'lazy'. So when you run the 'let [w (take 26 (words-with (current-word)))' section, nothing is being consumed and the re-matches part doesn't run until you ask for an item from the list. (So we haven't proved conclusively that to-array is slow, it could be re-matches or re- pattern (which is what I suspect). I think a better way to do this is to not use a regex at all. Canonically I think this sort of thing is (would be?) implemented by constructing a 'sequence' of strings, (first filtered based on potential word length) and recursively filtering based on 'character at position x' in the string, as characters are entered... the resulting seqs could be memoized. Then, you could type a letter and quickly update the options based on the new character at that position (by simply filtering the stored sequence one more time). When you delete a letter, you run it and receive the memoized result from earlier. To display you would want to use 'into-array' and your 'setListData' function, because you seem to have a homogeneous collection of strings; while to-array makes you an array of objects, into-array will return an array of strings (It might help, I'm really not sure). -- 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 Note that posts from new members are moderated - please be patient with your first post. 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