Re: join* tables from csv

2016-10-18 Thread Alan Thompson
You may also like this answer using DataScript to solve a similar problem:


http://stackoverflow.com/questions/39712460/how-to-map-different-values-from-2-sets-in-clojure-based-on-unique-value/39714081#39714081

On Tue, Oct 18, 2016 at 6:09 AM, Moe Aboulkheir  wrote:

> (defn join* [d1 c1 d2 c2]
>   (clojure.set/join (into #{} d1) (into #{} d2) {c1 c2}))
>
> Or else look at the implementation of set/join.
>
> Take care,
> Moe
>
> On Tue, Oct 18, 2016 at 9:41 AM,  wrote:
>
>> Hey guys, i'm beginner and need help.
>>
>> I have a task:
>>
>> ;; (join* (join* student-subject :student_id student :id) :subject_id
>> subject :id)
>> ;; => [{:subject "Math", :subject_id 1, :surname "Ivanov", :year 1998,
>> :student_id 1, :id 1}
>> ;; {:subject "Math", :subject_id 1, :surname "Petrov", :year 1997,
>> :student_id 2, :id 2}
>> ;; {:subject "CS", :subject_id 2, :surname "Petrov", :year 1997,
>> :student_id 2, :id 2}
>> ;; {:subject "CS", :subject_id 2, :surname "Sidorov", :year 1996,
>> :student_id 3, :id 3}]
>> ;;
>> ;; Hint: reduce, conj, merge, first, filter, get
>> ;; Here column1 belongs to data1, column2 belongs to data2.
>> (defn join* [data1 column1 data2 column2]
>>   )
>>
>> so.. i'm trying to write join (defn join* [data1 col1 data2 col2] ... )
>> data1 and data2 like: ({:key1 val1 :key2 val2} {:key1 val3 :key2 val4})
>> after => example result.
>>
>> --
>> 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.
>

-- 
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.


Re: join* tables from csv

2016-10-18 Thread Moe Aboulkheir
(defn join* [d1 c1 d2 c2]
  (clojure.set/join (into #{} d1) (into #{} d2) {c1 c2}))

Or else look at the implementation of set/join.

Take care,
Moe

On Tue, Oct 18, 2016 at 9:41 AM,  wrote:

> Hey guys, i'm beginner and need help.
>
> I have a task:
>
> ;; (join* (join* student-subject :student_id student :id) :subject_id
> subject :id)
> ;; => [{:subject "Math", :subject_id 1, :surname "Ivanov", :year 1998,
> :student_id 1, :id 1}
> ;; {:subject "Math", :subject_id 1, :surname "Petrov", :year 1997,
> :student_id 2, :id 2}
> ;; {:subject "CS", :subject_id 2, :surname "Petrov", :year 1997,
> :student_id 2, :id 2}
> ;; {:subject "CS", :subject_id 2, :surname "Sidorov", :year 1996,
> :student_id 3, :id 3}]
> ;;
> ;; Hint: reduce, conj, merge, first, filter, get
> ;; Here column1 belongs to data1, column2 belongs to data2.
> (defn join* [data1 column1 data2 column2]
>   )
>
> so.. i'm trying to write join (defn join* [data1 col1 data2 col2] ... )
> data1 and data2 like: ({:key1 val1 :key2 val2} {:key1 val3 :key2 val4})
> after => example result.
>
> --
> 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.


join* tables from csv

2016-10-18 Thread evgeniy . kurpanov
Hey guys, i'm beginner and need help.

I have a task:

;; (join* (join* student-subject :student_id student :id) :subject_id 
subject :id)
;; => [{:subject "Math", :subject_id 1, :surname "Ivanov", :year 1998, 
:student_id 1, :id 1}
;; {:subject "Math", :subject_id 1, :surname "Petrov", :year 1997, 
:student_id 2, :id 2}
;; {:subject "CS", :subject_id 2, :surname "Petrov", :year 1997, 
:student_id 2, :id 2}
;; {:subject "CS", :subject_id 2, :surname "Sidorov", :year 1996, 
:student_id 3, :id 3}]
;;
;; Hint: reduce, conj, merge, first, filter, get
;; Here column1 belongs to data1, column2 belongs to data2.
(defn join* [data1 column1 data2 column2]
  )

so.. i'm trying to write join (defn join* [data1 col1 data2 col2] ... ) 
data1 and data2 like: ({:key1 val1 :key2 val2} {:key1 val3 :key2 val4}) 
after => example result.

-- 
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.