Re: executing conditional if like iif from other languages

2014-05-08 Thread Atamert Ölçgen
On Fri, May 9, 2014 at 5:44 AM, Don Hill wrote: > I am trying to get a couple of edge cases to past and since I am very new > to clojure/lisp (2 days total) I thought I would ask. > > > I am using defmacro like the following. I have 2 edge case which are > failing. I would like to be able to proc

Re: Assuring dealing with PersistentVector for associative accesses

2014-05-08 Thread Joseph Rollins
Thanks, I haven't used pre and post conditions before but this seems like a good place to start. On Thursday, May 8, 2014 8:17:53 PM UTC-4, James Reeves wrote: > > If you're representing a matrix with vectors, then any public function > that operates on a matrix should return vectors. > > You ma

Re: Tag classes required to be imported?

2014-05-08 Thread Colin Fleming
Thanks Andy. Actually it looks like CLJ-1232is the exact problem in Clojure (linked from TANAL-24 ). On 9 May 2014 00:48, Andy Fingerhut wrote: > Forgot to mention, the type tag should work without having

Re: Assuring dealing with PersistentVector for associative accesses

2014-05-08 Thread James Reeves
If you're representing a matrix with vectors, then any public function that operates on a matrix should return vectors. You may want to consider a function like: (defn matrix? [m] (and (vector? m) (every? vector m) (apply = (count m) (map count m))) Then add it as a pre and post

Re: Assuring dealing with PersistentVector for associative accesses

2014-05-08 Thread Joseph Rollins
This works for all cases were I transform the matrix using map, but I also transform it using reverse and assoc. On Thursday, May 8, 2014 8:02:03 PM UTC-4, Jason Ozias wrote: > > Take a look at mapv. If you aren't dealing with lazy sequence, it'll map > the function across and convert the outpu

Re: Assuring dealing with PersistentVector for associative accesses

2014-05-08 Thread Jason Ozias
Take a look at mapv. If you aren't dealing with lazy sequence, it'll map the function across and convert the output to a vector. On Thursday, May 8, 2014 7:28:47 PM UTC-4, Joseph Rollins wrote: > > I am confused about the best way to assure that I am dealing with a vector > when dealing with co

Assuring dealing with PersistentVector for associative accesses

2014-05-08 Thread Joseph Rollins
I am confused about the best way to assure that I am dealing with a vector when dealing with core library functions that often return seq where I then lose my ability to access it using associative accesses (get-in specifically). My particular use case is as follows: I am modeling a matrix as

executing conditional if like iif from other languages

2014-05-08 Thread Don Hill
I am trying to get a couple of edge cases to past and since I am very new to clojure/lisp (2 days total) I thought I would ask. I am using defmacro like the following. I have 2 edge case which are failing. I would like to be able to process these cases where there are extra bits and as you pro

Re: Immutable or Effectively Immutable?

2014-05-08 Thread Alexandru Nedelcu
On Wed, May 7, 2014 at 5:57 PM, Phillip Lord wrote: > In general, though, if I write some code like > > (if (instance? Cons x) > (pass-to-another-thread-without-synchronisation x)) > > I cannot guarantee the result of this because although I know that > the head of x is fixed, I cannot guarant

Re: Rethinking Literate Programming

2014-05-08 Thread Mark Engelberg
On Thu, May 8, 2014 at 11:02 AM, Mark Engelberg wrote: > In fact, Clojure has a number of features that actively hurt its > expressiveness relative to other modern languages: > BTW, that list was by no means exhaustive. In the past couple of hours I've thought of a couple more, I'm sure others c

Re: Immutable or Effectively Immutable?

2014-05-08 Thread Alexandru Nedelcu
On Wed, May 7, 2014 at 6:31 AM, Alex Miller wrote: It does matter with regard to visibility across threads - your example does > not use a synchronization mechanism and there is no guarantee that other > threads will ever see those changes (so don't ever ever do that :). But if > you stick to the

Re: Rethinking Literate Programming

2014-05-08 Thread u1204
> For example, did you know that > the book/literate program "Physically Based Rendering" recently won a > Scientific and Technical Academy Award? (Yes, that's right, a literate > program won an Academy Award -- the "Hollywood movie" kind.) An awesome book, b

Re: Rethinking Literate Programming

2014-05-08 Thread u1204
> PS. Just to be clear, my purpose is neither to attack nor to defend LP, > just to get clear about exactly what it is, what its presuppositions are, > what its implications are, etc. I also do not want to get into defending LP yet again. But I do think you might have missed the key point by focus

Re: Rethinking Literate Programming

2014-05-08 Thread Mark Engelberg
Greg, I can tell by the amount of work you've put into this document that this is an earnest attempt at analysis and not trolling, so I'm going to give you my earnest response: you are wrong on so many levels. First, you seem to have several misconceptions about literate programming in general,

Re: What does ^{} actually translate to?

2014-05-08 Thread Stephen Gilardi
On May 8, 2014, at 8:34 AM, Pascal Germroth wrote: > I'm trying to attach metadata to some values (not the vars holding them). > I thought ^{x} y was the same as (with-meta y {x}), There was a recent thread about this here. https://groups.google.com/forum/#!searchin/clojure/metadata$20reader/c

Re: determining repl environment vs. uberjar environment?

2014-05-08 Thread Dave Tenny
Gotcha. I suppose that makes sense as long as I undo some poor design and make sure that the 'exit' wrapper I have never attempts to call System/exit directly and always throws some suitable exception for interpretation at the top level. Right now my exit wrapper calls exit immediately if we're no

Re: determining repl environment vs. uberjar environment?

2014-05-08 Thread Ray Miller
On 8 May 2014 16:22, Dave Tenny wrote: > James, All well and good, but you still need to know if you're running in a > REPL environment, and make sure you do NOT call System/exit for any > (typical) reason in that environment. The idea is to test your (-main) > function from the REPL, without hav

Re: determining repl environment vs. uberjar environment?

2014-05-08 Thread Dave Tenny
James, All well and good, but you still need to know if you're running in a REPL environment, and make sure you do NOT call System/exit for any (typical) reason in that environment. The idea is to test your (-main) function from the REPL, without having to restart the lisp every time. On Thu, Ma

Re: data.xml namespace aware?

2014-05-08 Thread Herwig Hochleitner
Hi, I'm the guy working on the newer proposal, which is almost done (TM). It seems you have found the way to emulate namespacing with the current data.xml impl: by taking care of xmlns attributes and prefixes yourself. I definitely want to keep compatibility with that representation. Feel free to

Re: What does ^{} actually translate to?

2014-05-08 Thread James Reeves
^x attaches the metadata to a form *before* it is evaluated. The with-meta function attaches the metadata to a form *after* it's been evaluated. Generally speaking, the ^x form is used for attaching metadata used by macros and the Clojure compiler, whereas with-meta is used to attach run-time meta

Re: determining repl environment vs. uberjar environment?

2014-05-08 Thread James Reeves
Sure, but those return codes correspond to some ending state of your application, which can occur via a normal function return, or through an exception. In both cases, your -main function can map state to exit code. For instance, let's assume that your application will return or except. In example

Re: determining repl environment vs. uberjar environment?

2014-05-08 Thread David Powell
There are some hacky possibilities - eg testing for *1, but I don't think there is a definitive way; there are many repls too (the clojure.main repl, lein repl, lighttable), and a technique might not work on all of them. Probably best to have some helper function you call from the repl, and have t

Re: What does ^{} actually translate to?

2014-05-08 Thread guns
On Thu 8 May 2014 at 05:34:19AM -0700, Pascal Germroth wrote: > (def f1 "doc" ^{:x 1} (partial inc)) > (meta f1) ; nil, unexpected > (meta #'f1) ; contains :doc, but not :x, as expected The definition of partial is: (defn partial ([f] f) ([f arg1] (fn [& args] (apply f arg1 args))) …)

Re: determining repl environment vs. uberjar environment?

2014-05-08 Thread Dave Tenny
When running as an uberjar, i.e. "java -jar myapp.jar [args]" the return code of the process to the shell is very important. System/exit is how that return code is sent. On Thu, May 8, 2014 at 9:20 AM, James Reeves wrote: > Having your application call System/exit directly is often indicative

Re: determining repl environment vs. uberjar environment?

2014-05-08 Thread James Reeves
Having your application call System/exit directly is often indicative of some unnecessary coupling in your code. Under what circumstances does your application need to exit? - James On 22 April 2014 17:59, Dave Tenny wrote: > I have an app I'm building. It calls System/exit. That doesn't wo

Re: Rethinking Literate Programming

2014-05-08 Thread Gregg Reynolds
PS. Just to be clear, my purpose is neither to attack nor to defend LP, just to get clear about exactly what it is, what its presuppositions are, what its implications are, etc. -G On Thu, May 8, 2014 at 7:57 AM, Gregg Reynolds wrote: > The thread on documentation that Val started ( > https://

Rethinking Literate Programming

2014-05-08 Thread Gregg Reynolds
The thread on documentation that Val started ( https://groups.google.com/forum/?hl=en#!topic/clojure/oh_bWL9_jI0) is getting a little long so I'm starting a related one specific to litprog. I've made a start on rethinking LP at https://github.com/mobileink/codegenres/wiki/Rethinking-Literate-Progr

Re: Tag classes required to be imported?

2014-05-08 Thread Andy Fingerhut
Forgot to mention, the type tag should work without having to import it into the require'ing namespace if you fully qualify it where the tag is used. Andy On Thu, May 8, 2014 at 5:47 AM, Andy Fingerhut wrote: > This issue has been discovered before, at least in the context of the > tools.analyz

Re: Tag classes required to be imported?

2014-05-08 Thread Andy Fingerhut
This issue has been discovered before, at least in the context of the tools.analyzer library, and there was an ensuing discussion on the clojure-dev email list linked in the comments of this ticket: http://dev.clojure.org/jira/browse/TANAL-24 I do not recall whether there was a Clojure ticket

Re: determining repl environment vs. uberjar environment?

2014-05-08 Thread Dave Tenny
Here's a solution to the problem I was trying to solve. I'm not happy with it (the definition of has-repl?), but it's working for now. It's also Sun/Oracle JVM specific with the sun.java.command clause. Again, the problem is that I wanted an exit routine I could call that wouldn't terminate the j

Clojure TCP client using Java Socket

2014-05-08 Thread Dylan Gleason
I am trying to write a TCP client in Clojure for a networking assignment. While everyone else is using C or C#, I elected to use Clojure and Java sockets, but am naturally running into problems and can't figure out for the life of me what I am doing wrong. The goal is to send a message to the i

What does ^{} actually translate to?

2014-05-08 Thread Pascal Germroth
Hi, I'm trying to attach metadata to some values (not the vars holding them). I thought ^{x} y was the same as (with-meta y {x}), but while it works for f2/f4, f1's metadata is nowhere to be found, while f3 works as expected: (def f1 "doc" ^{:x 1} (partial inc)) (meta f1) ; nil, unexpected (meta