Best way to unit test

2018-03-28 Thread bj
What is the best way to write unit test case for following situation?

[date-for-validation]
(if (>= (Integer/parseInt current-date)
(Integer/parseInt date-for-validation)) true false))

-- 
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: How to apply multiple values to a function

2018-03-28 Thread Renata Soares
It worked, thanks!

Em quarta-feira, 28 de março de 2018 21:25:31 UTC-3, Moe Aboulkheir 
escreveu:
>
> Renata,
>
> It depends on what you want to with the results of treat-request.  If you 
> don't care about them, which seems like the case:
>
> (doseq  [[x y z] [x1 y1 z1] 
> [x2 y2 z2] [x3 y3 z3]]
>   (treat-request x y z))
>
> Is one way to accomplish it.  If you want a collection of the results, 
> replace doseq with for  (maybe 
> take a look at doall , also).
>
> In terms of the general approach - if the goal is to end up with a 
> sequence containing only the specified keys from each map (i.e. the 
> 'collection' argument is the same for all invocations), then you can 
> accomplish this without an atom:
>
> (for [[m ks] [[m1 ks1] [m2 ks2] ...]]
>   (select-keys m ks))
>
> Does just that.
>
> Take care,
> Moe
>
> On Thu, Mar 29, 2018 at 12:27 AM, Renata Soares  > wrote:
>
>> Good night,
>>
>> I have this function: 
>>
>> (defn treat-requests [input key-request collection]
>> (let [selecteds (select-keys input key-request)]
>> (swap! collection conj selecteds)))
>>
>> and I want to execute that 3 times with 3 differents arguments
>>
>> How can I do to apply a list of differents arguments to a function?
>>
>> Instead of calling 3 times like:
>>
>> (treat-request x1 y1 z1)
>> (treat-request x2 y2 z2)
>> (treat-request x3 y3 z3)
>>
>> I want to call one time. For example... (apply treat-request [x1 y1 z1] 
>> [x2 y2 z2] [x3 y3 z3]) 
>>
>>
>> -- 
>> 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.


Re: How to apply multiple values to a function

2018-03-28 Thread Moe Aboulkheir
Missed a set of parens:

On Thu, Mar 29, 2018 at 1:25 AM, Moe Aboulkheir  wrote:

> Renata,
>
> It depends on what you want to with the results of treat-request.  If you
> don't care about them, which seems like the case:
>

(doseq [[x y z] [[x1 y1 z1] [x2 y2 z2] [x3 y3 z3]]]
  (treat-request x y z))

-- 
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: How to apply multiple values to a function

2018-03-28 Thread Scott Thoman
On Wednesday, March 28, 2018 at 7:52:06 PM UTC-4, Renata Soares wrote:
>
> Good night,
>
> I have this function: 
>
> (defn treat-requests [input key-request collection]
> (let [selecteds (select-keys input key-request)]
> (swap! collection conj selecteds)))
>
> and I want to execute that 3 times with 3 differents arguments
>
> How can I do to apply a list of differents arguments to a function?
>
> Instead of calling 3 times like:
>
> (treat-request x1 y1 z1)
> (treat-request x2 y2 z2)
> (treat-request x3 y3 z3)
>
> I want to call one time. For example... (apply treat-request [x1 y1 z1] 
> [x2 y2 z2] [x3 y3 z3]) 
>
>
> How about something like (map (partial apply treat-request) [[x1 y1 z1] 
[x2 y2 z2] [x3 y3 z3]]) ?

/Scott

-- 
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: How to apply multiple values to a function

2018-03-28 Thread Moe Aboulkheir
Renata,

It depends on what you want to with the results of treat-request.  If you
don't care about them, which seems like the case:

(doseq  [[x y z] [x1 y1 z1] [x2
y2 z2] [x3 y3 z3]]
  (treat-request x y z))

Is one way to accomplish it.  If you want a collection of the results,
replace doseq with for  (maybe
take a look at doall , also).

In terms of the general approach - if the goal is to end up with a sequence
containing only the specified keys from each map (i.e. the 'collection'
argument is the same for all invocations), then you can accomplish this
without an atom:

(for [[m ks] [[m1 ks1] [m2 ks2] ...]]
  (select-keys m ks))

Does just that.

Take care,
Moe

On Thu, Mar 29, 2018 at 12:27 AM, Renata Soares 
wrote:

> Good night,
>
> I have this function:
>
> (defn treat-requests [input key-request collection]
> (let [selecteds (select-keys input key-request)]
> (swap! collection conj selecteds)))
>
> and I want to execute that 3 times with 3 differents arguments
>
> How can I do to apply a list of differents arguments to a function?
>
> Instead of calling 3 times like:
>
> (treat-request x1 y1 z1)
> (treat-request x2 y2 z2)
> (treat-request x3 y3 z3)
>
> I want to call one time. For example... (apply treat-request [x1 y1 z1]
> [x2 y2 z2] [x3 y3 z3])
>
>
> --
> 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.


How to apply multiple values to a function

2018-03-28 Thread Renata Soares
Good night,

I have this function: 

(defn treat-requests [input key-request collection]
(let [selecteds (select-keys input key-request)]
(swap! collection conj selecteds)))

and I want to execute that 3 times with 3 differents arguments

How can I do to apply a list of differents arguments to a function?

Instead of calling 3 times like:

(treat-request x1 y1 z1)
(treat-request x2 y2 z2)
(treat-request x3 y3 z3)

I want to call one time. For example... (apply treat-request [x1 y1 z1] [x2 
y2 z2] [x3 y3 z3]) 


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