Can you explain what the code is supposed to do in English? Java is a
little hard to read. :-)

Are you doing Huffman coding or similar?


On 18 August 2013 16:51, Hussein B. <hubaghd...@gmail.com> wrote:

> Hi!
>
> Would you please help me transforming this imperative code into functional
> one?
>
> The code is a typical snippet in imperative style. A lot of mutations that
> I don't even know how to start morphing it to Clojure.
>
> class Container {
>   Map<String, Container> children;
>   String letter;
>   List<String> value;
> }
>
> void insert(Container container, String letters, String value) {
>
>   for (int i = 0; i < letters.length; i++) {
>
>     String letter = new String(letters.chatAt[i]);
>
>     if (container.children.get(letter) != null) {
>       container = container.children.get(letter);
>     } else {
>       Map<Container> childContainer = new HashMap<>();
>       container.children.put(letter, childContainer);
>       container = container.children.get(letter);
>     }
>
>    if (i == letters.length() - 1) {
>      container.values.add(value);
>      break;
>    }
>
> }
>
>
> Thanks for help and time.
>
> --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to