On Wed, Jul 20, 2011 at 11:04 AM, Payam Mahmoudian <pa...@mahmoudian.info> wrote: > It's appreciated if you could help me to convert following C code into > clojure: > > float qTR(char *s1, char *s2) > { > int p,pl,q=0,r,s1l=strlen(s1),s2l=strlen(s2); > > for (p=0;p<s1l;p++) > for (pl=1;pl<=s1l-p;pl++) > for (r=0;r<s2l-pl+1;r++) > if (!memcmp(s1+p,s2+r,pl)) q += pl; > > > return((((s1l*q)/(s1l*(s1l+1)*(s1l+2)/6.0))+((s2l*q)/(s2l*(s2l+1)*(s2l+2)/6.0)))/(s1l+s2l)); > } > > Actually, I have a performance issue O(n^3), so I want to know if I > could use clojure concurrency feature in this case.
Welcome to Clojure! Ideally, you should have posted a new question instead of replying to an existing post. It messes up threads in the discussion, you know. Coming to your problem, it'd be great if you explain the problem and your proposed solution in English (or pseudo-code). It's hard for someone to convert imperative code written in C to functional Clojure by just looking at existing code. Approaches to solve the same problem differ and understanding the problem instead of looking at code helps. Besides, if the algorithm itself is O(N^3), I don't think concurrency can help you. Parallelism might, but one can't say without (again,) understanding the problem. Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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