Re: any? in clojure 1.9.0 alpha

2016-11-10 Thread waffletower
Not to try to force the last word, but I have already created the symmetry 
that I desire locally:

(defn not-not-any?
  [pred coll]
  (not (not-any? pred coll)))


On Tuesday, November 8, 2016 at 8:27:09 AM UTC-8, Colin Yates wrote:
>
> > Back at ya. I respect your opinion - I just see things differently. 
> I think that is the perfect way to end this conversation :-). 
>

I save a whole set of parens at least :)
I find no need to dwell and debate further -- my name is funnier and exalts 
in the asymmetry and wildness of programming. 

-- 
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: Using a function in another function

2016-11-10 Thread Max Countryman
The issue is (add1 (add1 [x])) is malformed: you probably mean (add1 (add1 x)).

An addn function could be implemented with iterate:

(defn addn [n x]
  (nth (iterate add1 x) n))


> On Nov 10, 2016, at 06:51, 'Rickesh Bedia' via Clojure 
>  wrote:
> 
> I have this function:
> (defn add1 [x]
> (+ 1 x))
> which is just a very simple function that adds 1.
> 
> I now want to create a new function called add2 that uses add1 twice.
> I have tried
> (defn add2 [x]
> (add1 (add1 [x]))
> but this doesn't work. (Can someone explain why this doesn't work. I think 
> its maybe I am calling the function incorrectly)
> 
> I have ideas about using recur because I eventually want to create a function 
> addn where the function takes arguments n and x and calls add1 n times to x
> 
> -- 
> 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: Using a function in another function

2016-11-10 Thread Colin Yates
Your inner (add1 [x]) is calling add1 with a vector containing x, you
want (add1 x):

(defn add2 [x]
(add1 (add1 x))

HTH

On 10 November 2016 at 14:51, 'Rickesh Bedia' via Clojure
 wrote:
> I have this function:
> (defn add1 [x]
> (+ 1 x))
> which is just a very simple function that adds 1.
>
> I now want to create a new function called add2 that uses add1 twice.
> I have tried
> (defn add2 [x]
> (add1 (add1 [x]))
> but this doesn't work. (Can someone explain why this doesn't work. I think
> its maybe I am calling the function incorrectly)
>
> I have ideas about using recur because I eventually want to create a
> function addn where the function takes arguments n and x and calls add1 n
> times to x
>
> --
> 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.


Using a function in another function

2016-11-10 Thread 'Rickesh Bedia' via Clojure
I have this function:
(defn add1 [x]
(+ 1 x))
which is just a very simple function that adds 1.

I now want to create a new function called add2 that uses add1 twice.
I have tried
(defn add2 [x]
(add1 (add1 [x]))
but this doesn't work. (Can someone explain why this doesn't work. I think 
its maybe I am calling the function incorrectly)

I have ideas about using recur because I eventually want to create a 
function addn where the function takes arguments n and x and calls add1 n 
times to x

-- 
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: [ANN] Advanced Martian usage

2016-11-10 Thread Oliver Hine
Hi Erik,

One of the philosophies of Martian was that it was not a "closed" system so 
that it made no demands on the server, and you can use it with servers that 
aren't yours and can't be changed. What you're describing is very much 
server-side testing, so Martian doesn't help directly there.

However, the description of endpoints using metadata is exactly how 
pedestal-api  works using Schema. In 
pedestal your routes are just a data structure so it would be easy to walk 
them, pull out the schema for the parameters of each handler and exercise 
them using test.check.
This is quite an interesting idea that would work well for "pure" handlers 
with no side effects, but once you add databases and things to the mix it 
could get trickier.

Let me know if you need any pointers on how to go about this.

Oliy



On Thursday, 10 November 2016 10:20:01 UTC, Erik Assum wrote:
>
> Hi Oliy, 
>
> In some ways this resonates with a thought I’ve had for a while, which 
> sort of appeared while working on a spring-boot application in java.
>
> So in Spring-boot, you have classes annotated as controllers, methods 
> annotated as request handlers which indicate what params and such they take.
> What I’d like (and which might very well exist, I haven’t researched this 
> yet) was a tool that exercised the methods in the controllers, directly 
> without involving http.
>
> So given something like this:
>
> @Controller
> public class MyController {
>
>   @RequestMapping(…)
>   public String helloWorld(@RequestParam(“name”) String name) {
> return “Hello “ + name;
>   }
> }
>
> I’d like something that found all the controllers, invoked the methods 
> annotated @RequestMethod with random data a la test.check
> and just verify that they returned “okish”, where I will not define 
> “okish” for now.
>
> And of course, I’d like to do some of the same with my ring app, e.g. 
> inspect all the routes in compojure, call the handlers (which I should have 
> spec’ed)
> and have them called with random test.check data and verify that return 
> “okish”
>
> I am aware of this being a huge oversimplification, with lots of pitfalls 
> and undefined behaviours, but I still find it an interesting idea.
>
> Erik.
>
> On 10 Nov 2016, at 10:56, Oliver Hine  
> wrote:
>
> Hi all,
>
> I wrote a blog post on some more advanced use of Martian, a library for 
> abstracting HTTP integration with other systems.
>
> All these use cases leverage the fact that Martian separates your data 
> (the *what*) from the HTTP implementation details (the *how*) and lets 
> you get on with connecting systems in valuable ways.
>
> The blog post includes the following topics:
>
>- Generative testing of HTTP integration 
>- Integration with non-swagger APIs
>- REST as a side effect: integrating Martian with re-frame
>
> You can read it all here: http://juxt.pro/blog/posts/advanced-martian.html
>
> Thanks,
> Oliy
>
> https://github.com/oliyh/martian
>
> -- 
> 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: [ANN] Advanced Martian usage

2016-11-10 Thread Erik Assum
Hi Oliy, 

In some ways this resonates with a thought I’ve had for a while, which sort of 
appeared while working on a spring-boot application in java.

So in Spring-boot, you have classes annotated as controllers, methods annotated 
as request handlers which indicate what params and such they take.
What I’d like (and which might very well exist, I haven’t researched this yet) 
was a tool that exercised the methods in the controllers, directly without 
involving http.

So given something like this:

@Controller
public class MyController {

  @RequestMapping(…)
  public String helloWorld(@RequestParam(“name”) String name) {
return “Hello “ + name;
  }
}

I’d like something that found all the controllers, invoked the methods 
annotated @RequestMethod with random data a la test.check
and just verify that they returned “okish”, where I will not define “okish” for 
now.

And of course, I’d like to do some of the same with my ring app, e.g. inspect 
all the routes in compojure, call the handlers (which I should have spec’ed)
and have them called with random test.check data and verify that return “okish”

I am aware of this being a huge oversimplification, with lots of pitfalls and 
undefined behaviours, but I still find it an interesting idea.

Erik.

> On 10 Nov 2016, at 10:56, Oliver Hine  wrote:
> 
> Hi all,
> 
> I wrote a blog post on some more advanced use of Martian, a library for 
> abstracting HTTP integration with other systems.
> 
> All these use cases leverage the fact that Martian separates your data (the 
> what) from the HTTP implementation details (the how) and lets you get on with 
> connecting systems in valuable ways.
> 
> The blog post includes the following topics:
> Generative testing of HTTP integration 
> Integration with non-swagger APIs
> REST as a side effect: integrating Martian with re-frame
> You can read it all here: http://juxt.pro/blog/posts/advanced-martian.html
> 
> Thanks,
> Oliy
> 
> https://github.com/oliyh/martian
> 
> -- 
> 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.


[ANN] Advanced Martian usage

2016-11-10 Thread Oliver Hine
Hi all,

I wrote a blog post on some more advanced use of Martian, a library for 
abstracting HTTP integration with other systems.

All these use cases leverage the fact that Martian separates your data (the 
*what*) from the HTTP implementation details (the *how*) and lets you get 
on with connecting systems in valuable ways.

The blog post includes the following topics:

   - Generative testing of HTTP integration 
   - Integration with non-swagger APIs
   - REST as a side effect: integrating Martian with re-frame

You can read it all here: http://juxt.pro/blog/posts/advanced-martian.html

Thanks,
Oliy

https://github.com/oliyh/martian

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