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 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" functions.
>
> Many thanks!
>
> -Jack
>
> On Fri, Jul 23, 2021 at 6:03 PM Cora Sutton  wrote:
>
>> 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 only evaluate when you actually want values out of
>> it.
>>
>> (defn evaluate-and-fns
>>   "Returns true if every function in members returns a value that is
>> true-ish according to Clojure's
>>   truthiness rules. Otherwise returns false."
>>   [members]
>>   (every? (fn [member]
>> (member))
>>   members))
>>
>> (defn evaluate-or-fns
>>   "Returns true if any function in members returns a value that is
>> true-ish according to Clojure's
>>   truthiness rules. Otherwise returns false."
>>   [members]
>>   (boolean
>>(some (fn [member]
>>(member))
>>  members)))
>>
>> (evaluate-or-fns [(fn []
>> (evaluate-and-fns [(fn [] (evaluate-and-fns
>> [simple-true-fn simple-true-fn]))
>>simple-true-fn]))
>>   (fn []
>> (evaluate-and-fns [simple-true-fn simple-false-fn]))])
>>
>> On Fri, Jul 23, 2021 at 7:22 PM Jack Park 
>> wrote:
>>
>>> 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
>>> some fn where fn is eval. That's the code.
>>> It's behaving strangely, but maybe I'm on the right track.
>>>
>>> Where this is going is that a list can be populated with things other
>>> than simple functions like SimpleTrue; can be populated with conjunctive
>>> and disjunctive lists, each of which can be similarly populated. That, of
>>> course, means that evaluating a single inferrable list is the same as
>>> walking a possibly complex (no loops, hopefully) spider web.
>>>
>>> Thanks
>>> Jack
>>>
>>> On Mon, Jul 19, 2021 at 6:04 PM Cora Sutton  wrote:
>>>
 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:

 https://gist.github.com/corasaurus-hex/1c86b545644b734310a15d984f61ad99

 Have a look, play with it a bit, change around value and see what
 breaks. Hope that's helpful!

 On Mon, Jul 19, 2021 at 5:55 PM Jack Park 
 wrote:

> 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 breaks and returns - without any errors - not a boolean, but the
> structure I passed it.
>
>
> On Mon, Jul 19, 2021 at 3:43 PM Cora Sutton  wrote:
>
>> 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 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]
>>>  #object[ie4clj.Tests$simple_false 0x3a4621bd
>>> ie4clj.Tests$simple_false@3a4621bd])
>>>
>>> Or maybe I missed something.
>>>
>>> On Mon, Jul 19, 2021 at 3:33 PM Cora Sutton  wrote:
>>>
 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 i

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 (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 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" functions.
>>
>> Many thanks!
>>
>> -Jack
>>
>> On Fri, Jul 23, 2021 at 6:03 PM Cora Sutton  wrote:
>>
>>> 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 only evaluate when you actually want values out of
>>> it.
>>>
>>> (defn evaluate-and-fns
>>>   "Returns true if every function in members returns a value that is
>>> true-ish according to Clojure's
>>>   truthiness rules. Otherwise returns false."
>>>   [members]
>>>   (every? (fn [member]
>>> (member))
>>>   members))
>>>
>>> (defn evaluate-or-fns
>>>   "Returns true if any function in members returns a value that is
>>> true-ish according to Clojure's
>>>   truthiness rules. Otherwise returns false."
>>>   [members]
>>>   (boolean
>>>(some (fn [member]
>>>(member))
>>>  members)))
>>>
>>> (evaluate-or-fns [(fn []
>>> (evaluate-and-fns [(fn [] (evaluate-and-fns
>>> [simple-true-fn simple-true-fn]))
>>>simple-true-fn]))
>>>   (fn []
>>> (evaluate-and-fns [simple-true-fn
>>> simple-false-fn]))])
>>>
>>> On Fri, Jul 23, 2021 at 7:22 PM Jack Park 
>>> wrote:
>>>
 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
 some fn where fn is eval. That's the code.
 It's behaving strangely, but maybe I'm on the right track.

 Where this is going is that a list can be populated with things other
 than simple functions like SimpleTrue; can be populated with conjunctive
 and disjunctive lists, each of which can be similarly populated. That, of
 course, means that evaluating a single inferrable list is the same as
 walking a possibly complex (no loops, hopefully) spider web.

 Thanks
 Jack

 On Mon, Jul 19, 2021 at 6:04 PM Cora Sutton  wrote:

> 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:
>
> https://gist.github.com/corasaurus-hex/1c86b545644b734310a15d984f61ad99
>
> Have a look, play with it a bit, change around value and see what
> breaks. Hope that's helpful!
>
> On Mon, Jul 19, 2021 at 5:55 PM Jack Park 
> wrote:
>
>> 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 breaks and returns - without any errors - not a boolean, but the
>> structure I passed it.
>>
>>
>> On Mon, Jul 19, 2021 at 3:43 PM Cora Sutton  wrote:
>>
>>> 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 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]
  #object[ie4clj.Tests$simple_false 0x3a4621bd
 ie4clj.Tests$simple_false@3a4621bd])

 Or maybe I missed something.

 On Mon, Jul 19, 2021 at 3:33 PM Cora Sutton  wrote:

>