Manoj, On Jun 30, 2009, at 8:55 PM, mmwaikar wrote:
> I am learning clojure these days, but on .Net. I have the following > code - > > (import '(System.IO Path Directory File DirectoryNotFoundException)) > > (defn starts-with-hmorx [name] > (if (or (= (.ToUpper (.ToString name)) "H") > (= (.ToUpper (.ToString name)) "M") > (= (.ToUpper (.ToString name)) "X")) true false)) > > (defn GetSubfolderName [filename] > ((def name-wo-extn (Path/GetFileNameWithoutExtension filename)) > (def first-char (aget (.ToCharArray (.ToString name-wo-extn)) 0)) > (if (Char/IsDigit first-char) (Convert/ToInt32 first-char) (if > (starts-with-hmorx first-char) (.ToLower (.ToString first-char)) > "other")))) I think you want something like this instead: (defn GetSubfolderName [filename] (let [name-wo-extn (Path/GetFileNameWithoutExtension filename) first-char (aget (.ToCharArray (.ToString name-wo-extn)) 0)] (if (Char/IsDigit first-char) (Convert/ToInt32 first-char) (if (starts-with-hmorx first-char) (.ToLower (.ToString first-char)) "other")))) The nested if is a little unusual though. I would probably rewrite it to use cond. If you can get a repl going, try to step through each expression and see where the problem is that way. I don't have Clojure .NET set up to give a more precise answer unfortunately. — Daniel Lyons --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---