<beneroth>
you should any/1 to the standard library :P
<Regenaxer>
'any' has a different meaning in Lisp
<beneroth>
*add
<Regenaxer>
should be 'nonNil' or so
<Regenaxer>
ugly
<beneroth>
hm..true
<beneroth>
well its 'any in the function documentation syntax
<beneroth>
but yes, completely no relation to the picolisp (any) function
<Regenaxer>
No, the any type includes also NIL
<beneroth>
then define it as any?/1 ?
<beneroth>
it does? hm
<Regenaxer>
any value
<beneroth>
ok
<beneroth>
then true/1 ?
<Regenaxer>
It is outside of Pilog
<beneroth>
true/0 already exists
<Regenaxer>
yes
<beneroth>
unsure if true/1 would be elegant or not so much
<Regenaxer>
(nil @Var) T (fail)
<Regenaxer>
is probably the Pilog way
<beneroth>
the prolog way. too long for picolisp/pilog way
<beneroth>
what about
<beneroth>
some/1
<beneroth>
?
<Regenaxer>
reads if it is NIL, then fail and don't backtrack
<beneroth>
nice example for cut operator
aw- has quit [Quit: Leaving.]
<Regenaxer>
No, should not be in the standard I think. It is too foreign ;)
<Regenaxer>
hmm
<Regenaxer>
then (equal @Var NIL) ?
<beneroth>
I agree when we talk about prolog. I disagree for pilog, I don't believe you don't require (^ @ (val (-> @Var)) in any advanced pilog program :P
<Regenaxer>
did not test
<beneroth>
then why does nil/1 exist? :P
<Regenaxer>
yeah
<beneroth>
works
<beneroth>
: (? @X NIL (equal @X NIL))
<beneroth>
@X=NIL
<beneroth>
:
<beneroth>
-> NIL
<Regenaxer>
cause NIL is a normal value
<beneroth>
: (? (equal @NotDefined NIL))
<beneroth>
@NotDefined=NIL
<beneroth>
-> NIL
<beneroth>
:
<beneroth>
T
<beneroth>
so why is nil/1 in the standard then :P
<beneroth>
you make arguments for my case, not yours :D
<Regenaxer>
So better remove nil/1 ?
<beneroth>
it is too foreign, too :P
<beneroth>
I'm for adding both, both are syntax sugar not essentials, but I would say you need them in nearly every pilog program
<beneroth>
as in nearly all pilog program you want to work with pilDB and lisp data, and then you need it certainly
<Regenaxer>
I never needed to check for non-Nil
<beneroth>
really?
<beneroth>
I have a hard time believing this :D
<beneroth>
well ok granted, I do something rather innovative here, if I may be so smug.
<beneroth>
how often are using nil/1 then?
<Regenaxer>
I still believe there is a more "correct" way
<Regenaxer>
for non-Nil
<Regenaxer>
i.e. a no-op
<beneroth>
yeah.. but then it must into the pilog vm, no?
<Regenaxer>
non-unified vars is in the vm
<beneroth>
you cannot use @Var without a clause around it, not like (and @Var ...) in picolisp, can you?
<Regenaxer>
you can and do
<beneroth>
nvm, my last message is bullshit
<Regenaxer>
in any place
<Regenaxer>
it is always expanded and matched
<beneroth>
well yes but NIL does not equal (fail) in pilog
<Regenaxer>
also in nested patterns etc.
<beneroth>
or?
<Regenaxer>
NIL means not unified
<beneroth>
sure?
<Regenaxer>
sure about what?
<beneroth>
hm yes
<beneroth>
you are right
<Regenaxer>
I use @Var for a complete sub-expression sometimes
<Regenaxer>
Pilog simply expands it
<Regenaxer>
and the result is used further
<Regenaxer>
(or ((nil @Var) T (fail)) (something-true))
<beneroth>
I'd be interested in some examples of that
<beneroth>
might teach me the missing piece for recursion
<beneroth>
I want to do check if a @Var is in a list property of an @Obj
<Regenaxer>
I ended up always with (; (-> @Obj) foo)
<beneroth>
I see
<Regenaxer>
Pilog has no concept of properties
<Regenaxer>
so we need Lisp
<beneroth>
prolog hasn't. pilog kinda has, as it has a concept of get algorithm
<beneroth>
ok
<Regenaxer>
I was thinking to extend '->' in pil21
<beneroth>
yeah I missed the bit about not unyifing
<Regenaxer>
but did not
<beneroth>
extend for?
<Regenaxer>
i.e. (-> @Obj NIL 'foo)
<Regenaxer>
but thats not helpful
<Regenaxer>
additional args for '->'
<Regenaxer>
(; (-> @Obj) foo) is clearer
<beneroth>
not really needed
<beneroth>
exactly
<Regenaxer>
yeah
<beneroth>
I fully agreee
<Regenaxer>
cause the second arg for -> is already used
<beneroth>
ah
<Regenaxer>
a number
<beneroth>
currently I have an (or ((()) which compares a string @Var with multiple properties of an object
<beneroth>
so I should better create a single rule for that, and do the or in picolisp, not in pilog, eh?
<Regenaxer>
I think 'or' should be avoided
<beneroth>
yeah it creates branches
<beneroth>
I see
<beneroth>
makes sense
<Regenaxer>
I use it only in select filters
<Regenaxer>
to make them in one place
<beneroth>
it is a about a select filter, T
<Regenaxer>
ok
<Regenaxer>
multiple 'be' are better and are the same
<beneroth>
(select (@Org)
<beneroth>
((id +Org))
<beneroth>
((same @Name @Org main-name))
<beneroth>
((same @Name @Org short-name))
<beneroth>
(or
<beneroth>
((same @Aliases @Org aliases)
<beneroth>
(member @Name @Aliases) ) ) )
<beneroth>
will do a rule for it
<beneroth>
thanks!
<beneroth>
(above code is wrong, because same is not unifying, the member always matches)
<Regenaxer>
I think you can use a single 'member' here
<beneroth>
how?
<beneroth>
that was my big issue on the weekend
<beneroth>
how to generate a list of values into/for a single pilog variable
<Regenaxer>
Sorry, mistake
<Regenaxer>
cause of the properties
<beneroth>
ok
<Regenaxer>
I meant something like
<beneroth>
yeah I know how I can generate values with member/2 :)
* beneroth
listens
<Regenaxer>
(or (same @Name @Foo) (same @Name @Bar) (member @Name (a b c)))
<Regenaxer>
-> (member @Name (@Foo @Bar a b c)))
<beneroth>
aaah
<Regenaxer>
So not useful with the above get's
<beneroth>
thanks, that just teached me how to do a list in pilog :)
<beneroth>
T
<Regenaxer>
T
<Regenaxer>
always expands
<Regenaxer>
or substitutes
<beneroth>
what do you think of that?
<beneroth>
(be org-has-name (@Org @Name)
<beneroth>
(^ @
<beneroth>
(or
<beneroth>
(let? Name (-> @Name)
<beneroth>
(with (-> @Org)
<beneroth>
(= Name (: main-name))
<beneroth>
(= Name (: short-name))
<beneroth>
(member Name (: aliases)) ) ) ) ) )
<Regenaxer>
this is surely the fastest
<beneroth>
and not considered ugly (not talking about the property names ;-) )
<beneroth>
?
<beneroth>
is there a best practice for the ordering of parameters for pilog rules?
<Regenaxer>
I find it ok, as dropping into Lisp is always ugly kind of
<beneroth>
yeah I understand
<beneroth>
no way around it here, I think
<Regenaxer>
The ordering is even more a matter of taste perhaps
<beneroth>
yes. what would be good taste?
<beneroth>
is there one?
* beneroth
has no pilog/prolog taste, lack of experience
<Regenaxer>
It depends on the English reading
<beneroth>
ok
<Regenaxer>
(likes @A beer)
<Regenaxer>
or (likes beer @A)
<beneroth>
as I named the rule "org-has name" I went with @Org first
<Regenaxer>
yes, good
<beneroth>
has-name might be more prology
wineroots has joined #picolisp
<beneroth>
or even mabye (named)
<beneroth>
but I have other entities besides orgs, so I guess I want it in the rule name
<beneroth>
or I have to do (isa) within picolisp
<Regenaxer>
T
<beneroth>
I know about the effects of symbol name length in picolisp and database
<beneroth>
how about in pilog?
<Regenaxer>
Which effects do you mean?
<beneroth>
or is it all pointers during evaluation anyway? so only of interesting in the reading step as with picolisp?
<Regenaxer>
storing multiple times?
<Regenaxer>
all is pointers
<beneroth>
using shorter/longer names for pilog variables or pilog rules
<beneroth>
ok
<Regenaxer>
yes
<beneroth>
so the normal picolisp stuff applies, but nothing pilog-specific :)
<Regenaxer>
the serialied form
<beneroth>
makes sense
<beneroth>
thx :D
<Regenaxer>
the rules are not stored, right?
<beneroth>
no
<Regenaxer>
and if, only once
<beneroth>
hardcoded in a file, loaded when needed
<Regenaxer>
yeah
<Regenaxer>
so no problem
<beneroth>
T
<Regenaxer>
can be verrry long
<beneroth>
the names or the bodies?
<Regenaxer>
all of them
<beneroth>
or you mean the result T property values :D
<beneroth>
aye
<beneroth>
naturally
<beneroth>
did/do you store pilog rules in db? you came never actually around to do/need it, I understood?
<Regenaxer>
yes, never did in a project so far
ym has joined #picolisp
<beneroth>
ah btw. my pilog environment I use here is fully namespaced :)
<Regenaxer>
but might make sense
<beneroth>
yeah
<Regenaxer>
cool!
<beneroth>
it's really cool
<beneroth>
a few interfacing picolisp functions
<beneroth>
to change/reset state
<Regenaxer>
I like namespaces more and more
<beneroth>
and pilog rules to reason about data
<Regenaxer>
after getting used
<beneroth>
yeah
<beneroth>
I have similiar feelings about them as I have with C++ templates: extremely powerful, need to be fully grokked (half-assed knowledge just burns you), and rarely needed but when then it makes impossible things easy
<Regenaxer>
exactly
<Regenaxer>
a bit frighening ;)
<beneroth>
and as so often with picolisp, the relation to the mainstream understanding of the concept of the same name is uncanny at best :P
<beneroth>
like C++ templates vs. java generics. looks similiar, technically a similiar concept also under the hood, but function very differently, with very different pros and cons
<Regenaxer>
I don't know both well
<Regenaxer>
especially Java generics
<beneroth>
C++ templates are generators for classes, sames as classes are generators for structures + related functions
<Regenaxer>
yes
<beneroth>
java generics are just generalized containers, usually handling all their elements as pure Object class (the class everything inherits from).
<beneroth>
so generics don't generate, they are only generalized implementations
<Regenaxer>
I see
<beneroth>
which means they sometimes do non-obvious casting
<beneroth>
which results in non-obvious and sometimes non-deterministic performance behavior
<beneroth>
or so was my knowledge 10 years ago, possibly that java got better at this, but I'm not sure if it did.
<Regenaxer>
The best feature of pil21's namespaces is the 'priv' namespace used in (private)
<Regenaxer>
it behaves specially
<Regenaxer>
it is *searched* first
<beneroth>
no need for long (local) declarations
<Regenaxer>
but is *not* inserted
<beneroth>
so far I like to have explicit namespaces, so I can switch into them, useful for debugging
<beneroth>
can you switch into a private namespace?
<beneroth>
e.g. in repl
aw- has joined #picolisp
<Regenaxer>
not a long time
<Regenaxer>
it is like transients cleared
<beneroth>
ok
<beneroth>
so you can access it if you get symbols handed out of it, somehow
<Regenaxer>
But you can access the symbols with vip
<beneroth>
but not really :)
<beneroth>
oh okay
<Regenaxer>
yes
<beneroth>
yeah same as you can access transients, if you have a function which returns them
<Regenaxer>
they exist in 'priv' until the next (private) call
<Regenaxer>
(all 'priv)
<beneroth>
ok
<Regenaxer>
yes
<beneroth>
not affected by (load) like transient scope is?
<Regenaxer>
(all T)
<Regenaxer>
it is affected
<beneroth>
:(
<beneroth>
so explicit namespace is still needed if one wants to do intermediate loads
<Regenaxer>
But saved and restored
<beneroth>
ah ok
<Regenaxer>
Transients are saved now too
<beneroth>
ah that changed?
<Regenaxer>
seems so
<Regenaxer>
pil21/src/io.l
<beneroth>
so transients in a single source file are in the same scope, even if there is a (load) in the middle of the file. (load) is no longer same thing as (===) ?
<beneroth>
cannot let become the user active in a meaningful way
* beneroth
says sorry to English for treating it that bad
<Regenaxer>
:)
<tankf33der>
Hi all
<tankf33der>
regenaxer: how would you generate numbers from 1 till 1million where all digits are odd?
orivej has joined #picolisp
<Regenaxer>
I think with (for (I 1 (> 1000000 I) (+ I 2)) (printsp I))
<Regenaxer>
But if you can use self-modifying code, this is cute:
<Regenaxer>
(do 500000 (printsp (inc (-1) 2)))
<Regenaxer>
scnr ;)
<tankf33der>
What is scnr?
<Regenaxer>
Sorry could not resist (old netnews speak)
<Regenaxer>
you can of course also (let I -1 (do 500000 (printsp (inc 'I 2))))
<Regenaxer>
still smaller and faster than 'for'
<Regenaxer>
or, how about this?
<Regenaxer>
(for I 500000 (printsp (dec (* 2 I))))
<Regenaxer>
also nice
<Regenaxer>
but slow due to '*'
<tankf33der>
I see
<tankf33der>
I meant before: all digits of than resulting number are odd
<Regenaxer>
oh :)
<tankf33der>
not resulting number itself
<tankf33der>
:)
<Regenaxer>
I see
<Regenaxer>
Perhaps start with (1 1 1 1 1 1)
<Regenaxer>
The CAR is the lowest digit
<Regenaxer>
(prinl (flip L))
<Regenaxer>
then (inc L 2)
<Regenaxer>
if it is 11, dec by 2 and inc (cdr L)
<Regenaxer>
But there must be a better way, directly on numbers using arithmetics
<tankf33der>
I see
<Regenaxer>
not sure
<Regenaxer>
one digit is trivial
<Regenaxer>
after 5 steps add 10
<beneroth>
:D
<beneroth>
Regenaxer, what is the @ in (^ @ ...) ?
<beneroth>
parameter list for the anonymous lisp function?
<beneroth>
also removing the picolisp (val) from
<beneroth>
(be has-value (@Var)
<beneroth>
(^ @ (val (-> @Var))) )
<beneroth>
changed the behaviour
<beneroth>
pilog sometimes found it matching when it had no value
<Regenaxer>
yes, the var to bind
<Regenaxer>
(^ @N (* 3 4))
<beneroth>
ah
<beneroth>
so kinda like a return value
<Regenaxer>
*kind* of ;)
<beneroth>
I see
<beneroth>
any ideas about my problems with has-value ?
<beneroth>
maybe I use it wrong, well possible ;-)
<Regenaxer>
hmm, did not find any time
<beneroth>
ok
<beneroth>
it's not important now
<beneroth>
we can look into it another time
<Regenaxer>
:)
<beneroth>
thank you :)
<Regenaxer>
sorrys
<beneroth>
np, all good
<Regenaxer>
:)
<beneroth>
I appreciate you telling me having no time instead of not responding or disappearing ;-)
<Regenaxer>
Busy day today
<beneroth>
good!
Seteeri has joined #picolisp
ym has joined #picolisp
ym has quit [Remote host closed the connection]
ym has joined #picolisp
<Regenaxer>
So a 'value' predicate could be
<Regenaxer>
(be value (@Var @Val) (^ @Val (val (-> @Var))))
<Regenaxer>
(? (value {123} @X))
<Regenaxer>
gives @X = (+Cls) in this example (DB object)
<beneroth>
val/3 already exists
<beneroth>
0 property topic again
<Regenaxer>
yes, just as an example
<beneroth>
Regenaxer, I was talking again/still about the non-nil predicate
<Regenaxer>
for (^ @Val
<beneroth>
so it is a /1 predicate
<beneroth>
not for unifying
<beneroth>
I removed the (val) in my definition, and then I got wrong results
<beneroth>
even when the variables in question were clearly NIL
<Regenaxer>
I still don't understand why you need it
<Regenaxer>
to the example
<beneroth>
I have a list of picolisp variables, some have a value, some are NIL
<Regenaxer>
(^ @Val (val (-> @Var))) expands to
<Regenaxer>
(^ @Val (val (-> {123}))))
<Regenaxer>
So '->' is a fexpr
<Regenaxer>
Pilog substitutes
<beneroth>
my @Var binds to global picolisp variables, e.g. 'foo
<beneroth>
which might be NIL (on purpose)
<Regenaxer>
Can you give a short example?
<Regenaxer>
yes, and NIL is a value like 7
<beneroth>
yes
<Regenaxer>
not special in Pilog
<beneroth>
(setq foo 512 bar NIL) (? @Params '(foo bar) (member @Var @Params) (has-value @Var)) -> find all variables which are not NIL
<beneroth>
(the real case is a bit more involved, but I need this)
<beneroth>
(be has-value (@Var)
<beneroth>
(^ @ (val (-> @Var))) )
<beneroth>
that one works fine (with (val ..))
<beneroth>
if I remove the (val) from (val (-> @Var)) then it succeeds sometimes even when it should not
<Regenaxer>
I would do just (? @Params '(foo bar) (member @Var @Params) (^ @ (val (-> @Var))))
<beneroth>
yeah
<Regenaxer>
So it is just a naming problem?
<beneroth>
I use the has-value at multiple places, so I like to keep it just for readability. I'm aware I could hardcode it
<beneroth>
no, I'm wondering why
<beneroth>
(? @Params '(foo bar) (member @Var @Params) (^ @ (-> @Var)))) is not working
<Regenaxer>
yes, the body is (^ @ foo)
<beneroth>
ah yes
<beneroth>
makes sense
<beneroth>
of course
<beneroth>
thx
* beneroth
feels stupid now xD
<beneroth>
would (^ @ (bool (-> @Var)) be any better than (^ @ (val (-> @Var)) ?
<beneroth>
I'd guess (val ...) is better
<Regenaxer>
hmm
<Regenaxer>
bool is perhaps better
<Regenaxer>
expresses what you mean
<Regenaxer>
In which cases does it work without 'val'?
<beneroth>
(bool) doesn't work, I guess because it gets substituted into (bool 'foo)
<beneroth>
so with bool it would need to be (^ @ (bool (val (-> @Var)))
<Regenaxer>
right
<Regenaxer>
needs val in any case
<beneroth>
so I stay with (val) :)
<beneroth>
that I don't care about the result is visible from the @ in (^ @ ...)
<Regenaxer>
we needed Lisp *only* to access the value
<beneroth>
exactly
<Regenaxer>
yes, the value itself is not needed here
<beneroth>
that is the use case I use pilog here for: checking if globales have a value, and in some cases setting their value depending on which other globales have one or not
<Regenaxer>
ok
<beneroth>
I use it for a complex autocompletion process :)
<beneroth>
a bit unusual use of pilog, but perfect
<beneroth>
my pilog stuff is the rules which values/variables can autocomplete which other variables under which circumstances
<Regenaxer>
cool
<beneroth>
I find it extremely cool :D
<Regenaxer>
:)
<beneroth>
and very useful & needed for my use case here