Hi Francesco,

You want to decouple your code from the data that it is operating on, so
your code can operate regardless of the contents of the list. Otherwise,
you'll need code that matches the list, in which case it could all be code
anyway. Operating on arbitrary lists makes it easy to test simple examples
too.

A simple way to create links between pages might be like this (assuming
that conn is in scope and initialized):

(for [list-elt1 the-list, list-elt2 the-list :when (not= list-elt1
list-elt2)]
  (let [page1 (page-fn list-elt1)
        page2 (page-fn list-elt2)
        rel (nrl/create conn page1 page2 :links)]
  ;; do something with rel
  ))

This creates links both ways.

If you only want one-way links then the first approach that comes to mind
(there are others, and they're probably better) is to index through the seq:

(for [n (range (count the-list)), m (range (inc n) (count the-list))]
  (let [page1 (page-fn (nth the-list n))
        page2 (page-fn (nth the-list m))
        rel (nrl/create conn page1 page2 :links)]
  ;; do something with rel
  ))

The general idea here is to use an arbitrary var to represent your list
elements and pages.

Does this address your issue?

Regards,
Paul



On Tue, Jun 10, 2014 at 1:04 PM, Francesco Lunelli <
francesco.lune...@gmail.com> wrote:

> Thanks for the answer, I try to explain better what I have to do.
>
> I need to create some nodes in Neo4j then I need to create relationships
> between those nodes.
>
> This is an example taken from necons doc.
>
> (let [conn  (nr/connect "http://localhost:7474/db/data/";)
>         page1 (nn/create conn {:url "http://clojurewerkz.org"})
>         page2 (nn/create conn {:url "http://clojureneo4j.info"})
>         ;; a relationship that indicates that page1 links to page2
>         rel   (nrl/create conn page1 page2 :links)]
>     (println rel)))
>
> They create two nodes called page1 and pag2 then connect them.
>
> In my case I have a list of names, I want to create one node for each of
> them with the possibility to work on nodes after they are created.
> So if I have for example  a list like this one (def mylist '(j"john"
> "paul" "mary")) I want to create three nodes calling them john paul and
> mary storing the value "John" "Paul" "Mary" and after having created them I
> want to be albe to connect nodes creating a relationship among them, with a
> funciont like   rel   (nrl/create conn john paul :friend)]
>
> I hope this example explain better my needs.
>
> Thanks in advance
>
> Francesco
>
>
> On Tuesday, June 10, 2014 6:11:16 PM UTC+2, James Reeves wrote:
>
>> Could you explain a little more what your end goal is?
>>
>> It sounds like you want a map, but without knowing more about the
>> purpose, it's difficult to say.
>>
>> - James
>>
>>
>> On 10 June 2014 16:43, Francesco Lunelli <francesc...@gmail.com> wrote:
>>
>>> Hello everybody, I have a newbie question about destructuring and
>>> assigning and didn't find an answer in documentation or books.
>>>
>>> I have a list that contains an arbitrary number of elements for example
>>> '("one" "two" "three" ...) I now only that elements are strings.
>>>
>>> I need to to take every element and use it as the name of a variable
>>> inside a let and assign the result of a funcion on that element to that
>>> variable.
>>> Somthing like this for example:
>>>
>>> (let [one  (clojure.string/capitalize "one")
>>>       two (clojure.string/capitalize "two")
>>>       three (clojure.string/capitalize "three")]
>>>      ;; here I have access to vars one two three etc.
>>>       )
>>>
>>> where the names of the vars are taken from the list and values are
>>> obtained applying a function on the corresponding element of the list (the
>>> capitalize function il only an example, it could be everything else).
>>>
>>> If I do in this way
>>> (for [word ["the" "quick" "brown" "fox"]] (let [word
>>> (clojure.string/capitalize word)] (prn word)))
>>> it works, but I need to access the variables outside of the cycle for,
>>> after having defined and assigned everyone because I need to put in
>>> relation some of them.
>>>
>>> Thanks to everybody
>>>
>>> Francesco
>>>
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> 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/d/optout.
>

-- 
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/d/optout.

Reply via email to