Re: Strange Vector failure

2021-07-24 Thread Jack Park
That's precisely how I coded it. Just need to run some tests, then on to more complex testing with nested lists and so forth. Thanks! On Sat, Jul 24, 2021 at 12:03 AM Cora Sutton wrote: > not, in clojure, is itself a function, so it would just be wrapping a > other function call in (not

Re: Strange Vector failure

2021-07-24 Thread Cora Sutton
not, in clojure, is itself a function, so it would just be wrapping a other function call in (not (my-fn)). there is no limit to the recursion here, you can have functions in functions in functions On Fri, Jul 23, 2021 at 9:54 PM Jack Park wrote: > Cora, > > That's simply amazing. I added one

Re: Strange Vector failure

2021-07-23 Thread Jack Park
Cora, That's simply amazing. I added one more "or" test: all-false. I confess, I'm not yet at the place where I look at that pattern and recognize it, but, thanks to you and to the other hints I received here, I now have something to work with. Next up for me will be to test the "not"

Re: Strange Vector failure

2021-07-23 Thread Cora Sutton
You can stay away from eval unless you have extremely special needs, really. I never use it myself. The evaluate-or-fns and evaluate-and-fns don't care what the function is, it could be another call to evaluate-or-fns or evaluate-and-fns, and in this way you can recurse as deeply as you desire and

Re: Strange Vector failure

2021-07-23 Thread Jack Park
Hello again, Cora (and list!) I have your gist running, then added a new feature https://gist.github.com/KnowledgeGarden/330b4147cd3d4909ef55684fc4c1f00d The first code was for conjunctive lists, I added disjunctive lists There, I started with some? but could not make the grade, ended up with

Re: Strange Vector failure

2021-07-23 Thread Jack Park
Ok. I got back to this, now running Cora's gist. It gives me a different place to explore these issues. More soon. Jack On Tue, Jul 20, 2021 at 5:31 PM Jack Park wrote: > Hi Cora, > > I got dragged away but plan to study your contribution, which I deeply > appreciate. > > My project plans to be

Re: Strange Vector failure

2021-07-20 Thread Jack Park
Hi Cora, I got dragged away but plan to study your contribution, which I deeply appreciate. My project plans to be a very simple clojure re-implementation of an inference engine I wrote in Forth more than 20 years ago, a kind of list processor in which you have an interface which advertises a

Re: Strange Vector failure

2021-07-19 Thread Cora Sutton
Hello again, Jack. I'm not sure what your code looked like before or looks like now but I think maybe a different way of helping you out with this is in order. Here's some code that does what I think you're going for and runs:

Re: Strange Vector failure

2021-07-19 Thread Jack Park
Did. That suggestion was made earlier. Did not change anything. Here's a test which ran just fine (def x (evaluate_and (list true true))) (println "A" x) (def y (evaluate_and (list true false))) (println "B" y) But, the moment I attempt to make a list with two functions in it, the code

Re: Strange Vector failure

2021-07-19 Thread Cora Sutton
Those are functions that call booleans as functions. Try this: (defn simple-true [] true) On Mon, Jul 19, 2021 at 5:41 PM Jack Park wrote: > Great points! > They are filled with functions which look like this > > (defn simple_true [] (true)) > > They are not booleans but functions which return

Re: Strange Vector failure

2021-07-19 Thread Jack Park
Great points! They are filled with functions which look like this (defn simple_true [] (true)) They are not booleans but functions which return a boolean. Here is a list of two of those as produced by the code: (#object[ie4clj.Tests$simple_false 0x3a4621bd ie4clj.Tests$simple_false@3a4621bd]

Re: Strange Vector failure

2021-07-19 Thread Cora Sutton
Your members list needs to be filled with things that can be called as functions, since that's what that code snippet does, and booleans definitely cannot be called as functions. That's what the error means, there's a boolean in your list and it's trying to cast it to an IFn (a Clojure function

Re: Strange Vector failure

2021-07-19 Thread Jack Park
Cora (every? (fn [member] (member)) members) works fine on [constantly true & false but fails with java.lang.Boolean cannot be cast to clojure.lang.IFn on the lists I construct. In truth, I thought all the code was working, but that turned out ot be an artifact of the test I designed. When I

Re: Strange Vector failure

2021-07-19 Thread Jack Park
So, that did the trick. No more defs or atoms, a few tweeks, and it ran. naming conventions brought into line with clojure. Next step is to prove it can return a false, and then continue adding features. Many thanks to all, and particularly to Tanya for reviewing my code. On Mon, Jul 19, 2021

Re: Strange Vector failure

2021-07-19 Thread Tanya Moldovan
I think you forgot to link it, but I think I found it :) You don't really need line 11. It will run without it. Don't use defs inside a function. Use let. Always. Don't use atoms inside a function. In fact, unless you

Re: Strange Vector failure

2021-07-18 Thread Jack Park
Cora, I agree. A gist was just submitted here. I'm in the clojurians slack; I have a weak memory of being there once before. But, happy to put a summary of this in #beginners as you suggest. On Sun, Jul 18, 2021 at 8:13 PM Cora Sutton wrote: > Code would be helpful for sure! Also, it might be

Re: Strange Vector failure

2021-07-18 Thread Jack Park
Tanya, Here is a gist with the three files being hacked at the moment; the test file is in a different place than I've sketched above. You will have to remove a couple of :remove lines from test because I didn't include that code - it's not in play yet. Hope that helps. The program is just a

Re: Strange Vector failure

2021-07-18 Thread Cora Sutton
Code would be helpful for sure! Also, it might be time to move this to Clojurians Slack http://clojurians.net/ There is a #beginners channel where volunteers are available to help in a more synchronous fashion which might help get to the bottom of this a bit quicker. On Sun, Jul 18, 2021 at

Re: Strange Vector failure

2021-07-18 Thread Tanya Moldovan
Hey, Could you share the code you have now? On Mon, 19 Jul 2021, 02:18 Jack Park, wrote: > Cora! > > I made those changes. It is still working to the degree it was, with the > same error > clojure.lang.LazySeq cannot be cast to clojure.lang.IFn > > > which, according to the intertubes, means

Re: Strange Vector failure

2021-07-18 Thread Jack Park
Cora! I made those changes. It is still working to the degree it was, with the same error clojure.lang.LazySeq cannot be cast to clojure.lang.IFn which, according to the intertubes, means that my buildAndList returns (value) instead of value. I tried flatten. No cigar. Thanks Jack On Sun, Jul

Re: Strange Vector failure

2021-07-18 Thread Cora Sutton
Hello again Jack, On Sun, Jul 18, 2021 at 6:21 PM Jack Park wrote: > (every? eval members) does not appear to work on a list of functions > designed to evaluate to a boolean. > If members is a list of functions then you would do: (every? (fn [member] (member)) members) Showing it work here:

Re: Strange Vector failure

2021-07-18 Thread Jack Park
(every? eval members) does not appear to work on a list of functions designed to evaluate to a boolean. That code is used in a function evaluateAnd Two simple tests (evaluateAnd [true true] --> true (evaluateAnd [true false] --> nil (why not "false" as the every? examples show?) The specific

Re: Strange Vector failure

2021-07-18 Thread Jack Park
Cora and Alex, I think you are both hitting some nails on their heads. Yes, the java mentality creates a kind of flow and patterns which clearly do not apply to clojure (eliding jokes like "what must they be smoking"). In java, I can make a list structure and do whatever I want with it -

Re: Strange Vector failure

2021-07-18 Thread Cora Sutton
Oh! I just saw your post from earlier and Alex's response, I strongly believe we have an XY problem here. In Clojure you most likely wouldn't use interfaces like this. We can move this discussion over there since Alex has kicked it off. On Sun, Jul 18, 2021 at 2:37 PM Cora Sutton wrote: > And

Re: Strange Vector failure

2021-07-18 Thread Cora Sutton
And for what it's worth, I hte how condescending that site ( https://xyproblem.info/) is. It could be so much kinder. On Sun, Jul 18, 2021 at 2:34 PM Cora Sutton wrote: > No worries! Deep Java experience is such a huge asset when it comes to > Clojure, there's nothing to be ashamed of! > >

Re: Strange Vector failure

2021-07-18 Thread Cora Sutton
No worries! Deep Java experience is such a huge asset when it comes to Clojure, there's nothing to be ashamed of! So, for reify, if I understand what you're attempting, I think you'd have something like: (reify ie4clj.api.Inferrable (evalMembers [members] (every? evalSelf members

Re: Strange Vector failure

2021-07-18 Thread James Reeves
You're missing the method name and arguments now. It should be: (reify INTERFACE (METHOD [ARGUMENTS] CODE)) On Sun, 18 Jul 2021, at 8:14 PM, Jack Park wrote: > Thank you, Cora. That's awesome, and it opens new issues for me. Here is my > revised code from your first level comment >

Re: Strange Vector failure

2021-07-18 Thread James Reeves
You have a "defn" there by mistake. On Sun, 18 Jul 2021, at 6:41 PM, Jack Park wrote: > I have a class which treats a sequence as a conjunctive list of objects > which, when evaluated, return a boolean. It is an attempt to use doseq to > walk along that list, evaluating each entry, and anding

Re: Strange Vector failure

2021-07-18 Thread Jack Park
Thank you, Cora. That's awesome, and it opens new issues for me. Here is my revised code from your first level comment (defn AndList [members] (reify ie4clj.api.Inferrable (every? evalSelf members) )) Which opens new issues: - Right at "(reify" I get this error message Syntax

Re: Strange Vector failure

2021-07-18 Thread Cora Sutton
Hi Jack! I could be wrong but I think this could just be: (every? eval members) I see a few things here that seem strange to me so I wanted to share a few points that might be helpful (or might not, let me know either way) for future code. * So typically you don't want to def or defn within