ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Check also http://www.picolisp.com for more information
Seteeri has quit [Ping timeout: 272 seconds]
orivej has quit [Ping timeout: 256 seconds]
_whitelogger has joined #picolisp
orivej has joined #picolisp
Seteeri has joined #picolisp
<beneroth> Regenaxer, do you have some time? pilog questions, but not related to DB
<Regenaxer> A little later perhaps" I'm on the road atm
<Regenaxer> s/"/?
<beneroth> ok
<beneroth> np
<beneroth> maybe it's even a topic for pilcon :)
<Regenaxer> ok, back
<Regenaxer> Perhaps it is a topic, or perhaps I don't know the answer
Seteeri has quit [Read error: Connection reset by peer]
Seteeri has joined #picolisp
<beneroth> I think topics are allowed even when you don't know the answer ;-)
<Regenaxer> sure
<Regenaxer> What are the pilog questions?
<beneroth> how to test for non-NIL?
<beneroth> (of a pilog variable)
<beneroth> (not (nil @X)) ?
<Regenaxer> yes
<Regenaxer> Not sure about a better way
<Regenaxer> eg (^ @ (-> @X))
<Regenaxer> (^ ) is faster probably
<Regenaxer> Testing for NIL is not normal, as a variable is always unified with something
<beneroth> it can be unified with nil in my use case, because I do (or ((foo @X)) ((bar @X)) (nil @X))
<beneroth> so @X defaults to NIL if the other predicates fail
<beneroth> ok to do so?
<Regenaxer> I think there must be a more Prolog-like way
<Regenaxer> But such cases occur
<Regenaxer> when data came from Lisp (or DB)
<beneroth> I believe this is such a one, because I practically want to try multiple things
<beneroth> matching data
<beneroth> yep exactly
<beneroth> one of the 'foo predicates is a pilog (db)
<beneroth> testing if @X is string would be (be str (@X)
<beneroth> (^ @ (str? (-> @X))) ) ?
<Regenaxer> yes
<Regenaxer> Is the above correct?
<Regenaxer> (or ((foo @X)) ((bar @X)) (nil @X)) ?
<Regenaxer> not ((nil .. ?
<beneroth> how do you mean
<Regenaxer> The parens
<beneroth> foo, bar and nil exclude each other
<beneroth> ah I think one is missing at the end
<beneroth> well
<beneroth> I tried (or (foo @X) (bar @X) (nil @X)) first
<Regenaxer> (or ((foo @X)) ((bar @X)) ((nil @X)))
<beneroth> that doesn't work
<Regenaxer> yes
<beneroth> I think the double parens are needed, because or takes lists
<Regenaxer> 'or' needs lists of clauses
<beneroth> yep
<beneroth> thx
<Regenaxer> 'or' is like three separate rules here
<beneroth> I want the 'or' to be true as long as one of the three rules is true
<Regenaxer> ok
<beneroth> order has no affect, right?
<beneroth> not like picolisp or
<Regenaxer> It is different, as it triggers backtracking
<Regenaxer> so the clauses may be evaluated more than once
<Regenaxer> i.e. if bar fails, foo is retried
<beneroth> yep
<beneroth> so I have to ensure somehow that not all three predicates in or can be true, or I get multiple results
<beneroth> right?
<Regenaxer> Yes, or use the cut operator
<Regenaxer> (or ((foo @X)) T ((bar @X)) ((nil @X)))
<Regenaxer> Will not backtrace back to foo
<beneroth> aah
<beneroth> why do I put the T after the foo clause, and not after bar ?
* beneroth hasn't really prolog knowledge
<Regenaxer> I think it is wrong above
<Regenaxer> nees something like ((bar) T)
<Regenaxer> or ((bar) T (fail))
<Regenaxer> :)
<Regenaxer> I *hate* Prolog
<Regenaxer> Anyway, the T on the 'or' level is wrong
<beneroth> ok
<Regenaxer> I should re-read about Prolog
<beneroth> so I need to learn about the prolog cut operator to optimize my pilog queries
<Regenaxer> been many years
<beneroth> you forgot more about it than I ever knew ;-)
<Regenaxer> hmm
<Regenaxer> The cut is critical sometimes
<Regenaxer> not so much for performance
<Regenaxer> but gives difficult results
<beneroth> well without cut it could end up in endless loops or too many results?
<Regenaxer> in some cases, yes
<beneroth> I'm confident with pilog database queries (select/3 etc). but now I've got the idea to use pilog to do data import / data fusion, e.g. deciding what values to keep after merging input with the current data in the database even when the input is incomplete or conflicting with the db
<Regenaxer> sounds interesting
<beneroth> so now I want to learn non-db pilog in a few hours
<beneroth> what still confuses me
<Regenaxer> :)
<beneroth> the pilog environment, so to say, is the facts/rules stored in T properties of global symbols, right?
<Regenaxer> right, DB uses only a subset usually
<beneroth> T
<Regenaxer> yes, typically global
<Regenaxer> they are stored in the 'T' property
<Regenaxer> (show 'append) for example
<beneroth> could be fully local by defining all facts/rules as clauses into a pilog query before passing it to prove etc?
<beneroth> yeah, I now use a picolisp namespace for this globales to avoid potential symbol name clashing
<Regenaxer> local means local symbols, not value bindings
<beneroth> T
<Regenaxer> the values are not used in Pilog
<beneroth> T
<beneroth> so I could have multiple pilog environments by having (let'ed) symbols for all rule names?
<Regenaxer> Not 'let'ed, as this handles only values
<beneroth> ah
<beneroth> so namespacing
<Regenaxer> yes
<Regenaxer> or dynamically set and reset the T property, but that is tedious
<Regenaxer> concerning PilCon, I could talk a little about data structures
<Regenaxer> some basic stuff
<beneroth> what about never calling (be) or (clause) but building a list with all these statements as picolisp query? before handing it to (goal) ?
<beneroth> ah we already have topics for pilcon? ok
<Regenaxer> this is fine
<Regenaxer> 'be' is just a frontend te 'assertz'
<beneroth> this is fine = would this result in the pilog environment being transient to the pilog call, not setting T on any global variables?
<Regenaxer> What is "this" here?
<beneroth> yeah I know I should not ask you to explain the internals of the pilog query data structure ;-)
<Regenaxer> assertz?
<Regenaxer> why not? :)
<Regenaxer> it is simple, a list of clauses stored in 'T'
<beneroth> yeah that part I see
<beneroth> the stuff (goal) creates
<Regenaxer> ah
<beneroth> hihi
<Regenaxer> right, thats involved
<Regenaxer> the bindings are assoc lists
<Regenaxer> lists of such lists for the backtracking levels
<Regenaxer> So a query does a lot of consing
<beneroth> T
<Regenaxer> What do you think if I don't do a screen share today
<beneroth> so picolisp namespacing is the way to "isolate" a pilog environment, yes?
<Regenaxer> and give R/O ssh access?
<Regenaxer> yes
<Regenaxer> the symbols
<beneroth> understood! thx
<Regenaxer> with their properties
<Regenaxer> :)
<beneroth> one could save them in pilDB. but there is a conflict about the use of the T property ;-)
<beneroth> so better e.g. save rules explicitly, and build an pilog environment by calling (be) etc.
<Regenaxer> why a conflict?
<beneroth> T property means object is deleted in pilDB ?
<beneroth> ofc doesn't have to save as object, but as external symbols directly
<beneroth> that would work,y eah
<Regenaxer> yes, in E/R context only
<beneroth> T
<beneroth> not on key-value level
<Regenaxer> but using assetz is more clear
<Regenaxer> 'be' is not good as it does not eval
<beneroth> currently I use (be) and (clause)
<beneroth> (be) for hardcoded pilog predicates in the loaded source file
<Regenaxer> 'clause' is fine too
<Regenaxer> ok
<beneroth> (clause) for dynamically created rules through picolisp function calls
<beneroth> and I wipe a list of all rule-names to reset the environment
<beneroth> and the environment (symbols) are in a namespace
<beneroth> that sounds ok, yeah?
<Regenaxer> yes, good
<beneroth> :)
<beneroth> thanks
<Regenaxer> :)
<beneroth> basic use case working now
<beneroth> will now try to implement complex rules
<Regenaxer> great
<beneroth> let's see how far I can get without understanding cut operator ;-)
<beneroth> likely I've to ask some more questions, but lets see how far I can go myself :)
<Regenaxer> ok, I should study the Prolog way of thinking again
<beneroth> thank you very much!
<beneroth> yeah I think I've here a use cause where it is perfect
<beneroth> use case
<beneroth> alternative would be a very big list of if statements, with repeated calls through them in some cases, and high probability that some edge cases are not handled
<Regenaxer> As I said last time, the idea of persistent Pilog was the initial trigger for the Pil DB
<beneroth> really?
<Regenaxer> but I never used it that way
<beneroth> so you worked with pilog before PilDB ?
<beneroth> woooow
<beneroth> yeah I see
<beneroth> nice idea
<Regenaxer> yes, it was already in 8kLisp
<Regenaxer> Pilog
<Regenaxer> Back to PilCon: What do you think if I don't do a screen share today, and open a read-only ssh?
<Regenaxer> I don't want to use the desktop pc
<beneroth> ah so everyone can connect to that ssh? or what do you mean?
<Regenaxer> in the dark cold cellar today ;)
<Regenaxer> yes
<beneroth> I don't understand what you mean by "open read-only ssh" ?
<Regenaxer> I do that often when working with Josef
<beneroth> some probably don't have linux or capable ssh clients.. but sure, give it a try
<Regenaxer> or the kids
<beneroth> oh
<beneroth> do it, let's see how it works
<Regenaxer> Could be PuTTY
<beneroth> T
<Regenaxer> ok
<beneroth> or MobaXTerm
<Regenaxer> let's try
<beneroth> MobaXTerm is a better putty, everything in a single tool
<beneroth> yeah sure
<Regenaxer> most have Windows probably
<Regenaxer> not sure
<Regenaxer> I just start and try
<Regenaxer> Screen share from Jitsi/Android does not work with older desktop browsers yet
<beneroth> wat? so you can share, and other mobile clients can receive it, but some browsers cannot receive the stream?
<Regenaxer> yes
<beneroth> I'll probably join by mobile today
<beneroth> weird
<Regenaxer> they show a blaack screen
<beneroth> stream should be stream, independent of source
<beneroth> so different encoding or so
<Regenaxer> Here on Debian Chromium works fine, but not Firefox
<beneroth> weird
<beneroth> sounds like codes
<beneroth> codecs
<Regenaxer> yes, strange
<Regenaxer> handling of screens
<beneroth> would make sense that android and chrome use similiar codecs
<beneroth> both google
<Regenaxer> maybe in the future
<beneroth> then on jitsi level the stream is just a container
<beneroth> yeah
<beneroth> well firefox will die.. not for a while, but eventually :(
<Regenaxer> So encoding for video and screen is different
<Regenaxer> yes :(
<beneroth> @streaming: I assume, I have no knowledge of how it is done in detail
<Regenaxer> me neither, not at all
<beneroth> I think I have to learn about cut
<beneroth> I manage already to build infinite loops :D
<Regenaxer> hehe
<beneroth> afk, time to listen some youtube and do some chores ;-)
<Regenaxer> youtube is a good idea, did not try
<Regenaxer> will do soon
m_mans has joined #picolisp
<m_mans> Hi all
<Regenaxer> Cheers m_mans!
<Regenaxer> I'll probably not see here during PilCon
m_mans has quit [Ping timeout: 256 seconds]
orivej has quit [Ping timeout: 256 seconds]
Seteeri has quit [Remote host closed the connection]
<tankf33der> my next project:
<Regenaxer> Prime tests?
<tankf33der> yeap
<tankf33der> probable prime test.
<Regenaxer> 👍
<tankf33der> also very interested in solving (2^2+1)/5 convertation
<tankf33der> by scratch from experience. looking forward.
<Regenaxer> (2^2+1)/5 with bigger numbers I presume :)
<tankf33der> yea
<tankf33der> i already solved all combinations several times, remember nothing. even algo names.
<Regenaxer> hehe
<Regenaxer> Your output is too high
orivej has joined #picolisp
<beneroth> Regenaxer, I have (setq *Params '(Foo)) (setq Foo 5)
<beneroth> I do (apply off *Params)
<beneroth> Foo is still 5
<beneroth> (off Foo) works
<beneroth> might it be possible that (apply off 'lst) doesn't work?
<beneroth> pil64, 20.7.4, so a bit outdated...
<beneroth> or where am I wrong?
<Regenaxer> 'off' cannot be applied. 'apply' wurks only with functions that evaluate their args (EXPRs and SUBRs)
<Regenaxer> (apply set *Params) should do
<Regenaxer> Though I don't understand the purpose. *Params looks like a function, why 'off' it?
<Regenaxer> Ah, no. I read (setq *Params '((Foo) (setq Foo 5)))
<Regenaxer> '((Foo) (setq ... would be a function
<Regenaxer> But *Params is a list '(Foo) so it makes sense
<Regenaxer> Anyway (apply set *Params) is fine
<beneroth> ah right
<beneroth> thx!
<Regenaxer> ☺
<Regenaxer> Perhaps an 'fapply' function would be useful?
<beneroth> maybe
<beneroth> but not required
<Regenaxer> T
<beneroth> (apply set *Params) is not fine when *Params is a list with more than 1 symbol ^^'
<beneroth> because *Params is a list, so the elements have a cdr which seems to be used by set
<Regenaxer> yes, sorrt
<Regenaxer> (mapc set *Params)
<beneroth> so (for E *Params (set E)) is the best way?
<Regenaxer> or this
<Regenaxer> mapc is better
<Regenaxer> alse (mapc set *Params 7) in pil21
<beneroth> why? I learned the thumb rule that for is better than mapping because mapping causes (length List) function calls?
<Regenaxer> (mapc set *Params (7 .)) in pil64
<beneroth> I see
<beneroth> 7-variant of (zero) ?
<Regenaxer> yes, but 'for' requires the same number of calls
<Regenaxer> (mapc set *Params ...) is the mechanism of the mapping funs
<Regenaxer> additiondl args to the function
<beneroth> T
<Regenaxer> (mapc zero L) is (mapc set L 0)
<Regenaxer> or (mapc set L (0 .)) in old pils
<beneroth> T
<beneroth> :D
<beneroth> btw I think my pilog-approach is working
<Regenaxer> great!
<beneroth> once I stopped confusing myself with mixing multiple levels of the problem
<Regenaxer> Pilog rules :)
<beneroth> T
<beneroth> :)
<beneroth> the fun thing is
<beneroth> now I declare pilog rules
<beneroth> which define/bind a 'prg value to a pilog variable
<Regenaxer> interesting indeed
<beneroth> so I use pilog to determine which picolisp code I want to execute
<Regenaxer> very powerful
<beneroth> yeah. very warped kind of meta-programming
<Regenaxer> T
<beneroth> thanks for your help, sensei!
<Regenaxer> glad :)
<beneroth> this is advanced magic
<beneroth> let's see if it really works to the extend I need it
<Regenaxer> ok
orivej has quit [Ping timeout: 240 seconds]
orivej has joined #picolisp