Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer

Symbolic Butt posted:

the most surprising part of prolog to me is that it's kind of annoying to do arithmetic in it, I'm still trying to figure out a way for unification to work with some simple maths
http://www.swi-prolog.org/pldoc/man?section=clpfd does everything you would expect from a constraint solving maths thing, you just have to use slightly different operators

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

Internet Janitor posted:

the idea of prolog is to describe your input and output and the language furnishes a program.

The idea of prolog is that well, it's not so much about your input and output but your relationships between data.

The idea of prolog is that you describe the constraints of your data, and it works out if those constraints are satisfied.

Well,

It's a database. You write queries, and you can give some queries names.

Kinda,

It's a parser. Prolog is about nested grammars. You don't write a program, but do write a grammar.

And Yes

You can do reversible programming, or program generation.

But you do it by specifying the rules and then using prolog as a rules engine.

quote:

in trivial cases this works. in meaningful cases it's intractable. in practice, the idea of prolog was a complete failure.

the idea that prolog had a single idea is kinda laughable given how it was invented twice for different reasons.

the french (well, marseilles) team had been writing a generic parser, and had come up with an annotated grammar. the uk (well, edinburgh) group had been working on resolution algorithms independently, and discovered that another group had already implemented it without a formal model.

there was the prolog fad in 1980 when we thought machine learning was impossible and so we had to build expert rule systems to solve every problem


quote:

prolog the actual language is kind of a neat way of thinking about some things, though.

the irony is that: the ideas of prolog have been a success, the implementations of prolog on the other hand...

i mean that SLD resolution, unification, logic variables show up in other places in various forms.


quote:

writing programs that are not restricted to a narrow domain is intrinsically, inescapably difficult. we still can't really teach humans how to compose complex programs, so it shouldn't be surprising that we have met with limited success in replacing programmers with programs. i think the best thing to aim for is tools and techniques to help people manage the complexity of software, rather than hoping to hide it or make it disappear via some sleight of hand.

the whole 'replacing humans with programs' thing is some weirdo sales pitch from someone desperate for funding

tef
May 30, 2004

-> some l-system crap ->
gosh this whole 'the program doesn't describe a total ordering for evaluation' is weird

*writes a makefile and watches how the runtime sorts the build rules into an order for trying*

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
i am seriously considering prolog for a thing at work

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
Can I suggest: don't

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Destroyenator posted:

http://www.swi-prolog.org/pldoc/man?section=clpfd does everything you would expect from a constraint solving maths thing, you just have to use slightly different operators

holy poo poo this is exactly what I needed, thanks a lot

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
We have prolog in our game engine. Don't ask me why

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

Gazpacho posted:

Can I suggest: don't

just use bash instead

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Suspicious Dish posted:

We have prolog in our game engine. Don't ask me why

why

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
for AI i bet

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Gazpacho posted:

for AI i bet

my bet is on ~*~interactive fiction~*~

Doom Mathematic
Sep 2, 2008

Suspicious Dish posted:

We have prolog in our game engine. Don't ask me why

Procedural generation of instances of some kind of puzzle which have to be guaranteed solvable?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Symbolic Butt posted:

my bet is on ~*~interactive fiction~*~

ding ding ding

tef
May 30, 2004

-> some l-system crap ->
i don't know what to make of this

like prolog is good because it is bad

akadajet
Sep 14, 2003

i only had to look at prolog for like 1 week in college, then i've never seen it again.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Yeah, don't ask me how it worked, it was another team that worked on that project.

code:
expression_of_displeasure(_Data, A)-->
    ["[[ ", [subject,standard]-A, " scowls disapprovingly ]]"];
    ["[[ ",[subject,standard]-A, " rolls ", [object,possessive]-A, " eyes ]]"];
    ["[[ ",[subject,standard]-A, " sighs in frustration ]]"];
    ["[[ ",[subject,standard]-A, " scowls disapprovingly ]]"];
    ["[[ ",[subject,standard]-A, " scowls disapprovingly ]]"];
    ["[[ ",[subject,standard]-A, " forces a smile ]]"];
    ["[[ ",[subject,standard]-A," casts a sad look in your direction ]]"].

tef
May 30, 2004

-> some l-system crap ->
:2bong:

that's like a DCG but

i guess text generation makes some sense but wheee

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen
wow, prolog is hella overkill for that purpose.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
i assure you the actual actual prolog is a lot more complicated than that. it drove game state.

redleader
Aug 18, 2005

Engage according to operational parameters

Glorgnole posted:

labview doesn't let you zoom because lots of its interpretation of what the blocks in the window are supposed to do comes down to the relative positions of the pixels in the icons and wires

jesus loving christ

Presto
Nov 22, 2002

Keep calm and Harry on.

akadajet posted:

i only had to look at prolog for like 1 week in college, then i've never seen it again.

I had a whole semester with it. All I remember is writing a program to prove a guy was his own grandfather.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
?- :ins:

eschaton fucked around with this message at 10:21 on Mar 11, 2018

raminasi
Jan 25, 2005

a last drink with no ice
I prototyped an algorithm in Prolog once before implementing it for real, it worked really well.

also re visual programming: it’s a fantastic gateway drug for people who do complicated enough (domain-specific) work that it calls for programming but are intimidated by or disinterested in “programming” as an activity. “oh I’m not programming, this is ‘parametric modeling’.” “oh I don’t know much about programming, this is just a bespoke multimedia controller.”

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

amberpos.css needs to swap that out for a correct gif

akadajet
Sep 14, 2003

pokeyman posted:

amberpos.css needs to swap that out for a correct gif

i think amberpos being ever so slightly broken is the correct behavior

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
I've been playing with prolog lately to see if I get a deeper feel of the language, I'm doing this gameboy z80 assembler thing, that I hope eventually will result in a bespoke artisanal compiler.

so from a list of instructions I'm getting a list of assembled code.

code:
?- compile_list([instruction(ld, a, b), instruction(ld, d, 4), instruction(inc, de), instruction(inc, hl), instruction(dec, bc), instruction(nop)], X).
X = [120, 22, 4, 19, 35, 11, 0] ;
and I can do the opposite, if I did this right writing an assembler in prolog gives you a disassembler for free.

code:
?- compile_list2(X, [120, 22, 4, 19, 35, 11, 0]).
X = [instruction(ld, a, b), instruction(ld, d, 4), instruction(inc, de), instruction(inc, hl), instruction(dec, bc), instruction(nop)] ;
false.
but I messed something up and I'm trying to figure out what. I needed to write 2 separate rules for this, inverting the order of the facts

code:
compile_list(Instructions, AssembledList) :-
    encode_list(Instructions, MachineInstructions),
    assemble_list(MachineInstructions, AssembledList).

compile_list2(Instructions, AssembledList) :-
    assemble_list(MachineInstructions, AssembledList),
    encode_list(Instructions, MachineInstructions).
I'll keep the thread updated with my incompetent coding adventures

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer
it looks like it's all valid, you just aren't constraining the search well enough when you're going backwards. it's trying to build any list of instructions and then checking if they're a match for the assembled output you're providing

if you interrupt it and press g you can see what it's stuck trying to solve, it's just building an ever growing list of "nop"s and then testing that against the output list
code:
?- compile_list(X, [120, 22, 4, 19, 35, 11, 0]).
^CAction (h for help) ? goals
  [9] assemble_list([machine_instruction(opcode(0, 0, 0)), machine_instruction(opcode(0, 0, 0)), machine_instruction(opcode(0, 0, 0)), machine_instruction(opcode(0, 0, 0)), machine_instruction(opcode(0, 0, 0)), machine_instruction(opcode(0, 0, 0)), machine_instruction(opcode(..., ..., ...)), machine_instruction(...)|...], [120, 22, 4, 19, 35, 11, 0])
  [8] compile_list('<garbage_collected>', [120, 22, 4, 19, 35, 11, 0])

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
:sbahj:

yeah that gives me a much better idea of what's going on now, thanks for the tip

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Notorious b.s.d. posted:

we established long ago that you are too badly damaged by your career to understand the difference between good and bad.
btw good tech is what my employer allows me to use. bad tech is what i might wish i could use but would do better to just not think about lest i go mad

Notorious b.s.d.
Jan 25, 2003

by Reene

Gazpacho posted:

btw good tech is what my employer allows me to use. bad tech is what i might wish i could use but would do better to just not think about lest i go mad

Notorious b.s.d. posted:

we established long ago that you are too badly damaged by your career to understand the difference between good and bad.

tef
May 30, 2004

-> some l-system crap ->
i wrote a network transparent option parser

https://github.com/tef/textfree86

:2bong:

tef
May 30, 2004

-> some l-system crap ->
i'd post in the job thread or terrible thread but this is kinda an unspeakable horror that deserves to be here, i guess

here's the gist


if you have a command line program, you can expect some things to work: passing in a file name, and if you're lucky, tab completion:

code:
$ ./logdetails --uptime log.1
Wrote uptime to log

$ cat log.1
 5:59  up 2 days, 13:31, 12 users, load averages: 0.83 0.93 1.05

# Tell bash how to find completion information: (logdetails does it!)
$ complete -o nospace -C ./logdetails ./logdetails

$ ./logdetails --u<TAB>     # Using Tab Completion
--uname   --uptime  
If you have a command line program, and you run it via ssh, or docker run, some things just don't work the same.

code:
$ ssh machine ./logdetails filename   # filename is local to that machine

$ ssh machine ./logdetails  --<TAB>   # tab completion is for ssh, not grep
If you use textfree86, well, some things do work the same:

code:
$ ./textfree86.py 'ssh hostname /path/to/logdetails --pipe' -- output.log --uname
Wrote uname to log

$ cat output.log    # Written on the local machine!
Darwin

# We add alias, so we can add bash completion
$ alias rlogdetails='./textfree86.py ssh hostname /path/to/logdetails --pipe --'

$ rlogdetails --help
usage: logdetails [--uptime] [--uname] <output>

$ complete -o nospace -C rlogdetails rlogdetails
$ rlogdetails --u<TAB>    # Using Tab Completion
--uname   --uptime        # Yes, this calls ssh underneath!
so yeah i wrote a network transparent tab completion tool and option parsing library called textfree86

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



1) excellent name

2) in that last example, does it nest after the first command? its hard to tell what machine the commands are on because im dumb

tef
May 30, 2004

-> some l-system crap ->

Krankenstyle posted:

1) excellent name

ty

quote:

2) in that last example, does it nest after the first command? its hard to tell what machine the commands are on because im dumb

the last example is ./textfree86.py 'run this ssh command' -- 'then pass these arguments to it'

Ator
Oct 1, 2005

tab completion is so helpful

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
can’t you just do that completely in bash with complete -F and COMP_WORDS

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

rjmccall posted:

can’t you just do that completely in bash with complete -F and COMP_WORDS

I have no idea.

But this post made me think of all the times I developed some cool and complex system and then someone goes "can't you just do this completely obvious already-developed thing that if you had been better at research you'd have known about?"

and then i go "well poo poo"

TimWinter
Mar 30, 2015

https://timsthebomb.com
Writing your own version of something existent gives it unique flavor, a new take on an old standard. Like a carefully crafted loss edit.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

TimWinter posted:

Writing your own version of something existent gives it unique flavor, a new take on an old standard.

yeah that sounds cool and good--

TimWinter posted:

Like a carefully crafted loss edit.

oh no

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

rjmccall posted:

can’t you just do that completely in bash with complete -F and COMP_WORDS

i mean, it does use COMP_POINT and COMP_LINE because i wanted the setup to be 'add this line to complete' not 'download a bash function script and install it'

like i feel like this question comes from maybe not seeing what it's doing, but i guess my point isn't well explained

the point is that if i change the script on the remote end, the auto-complete suggestions change on the client

without editing my bash config settings or updating textfree86.py

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply