Re: Prolog as a scripting language
- From: ashley.fernandes@xxxxxxxxx
- Date: 27 Feb 2007 20:08:15 -0800
Ah, yes. Looks like I'm still thinking procedurally. Thanks.
On Feb 27, 8:04 am, Markus Triska <tri...@xxxxxxxx> wrote:
ashley.fernan...@xxxxxxxxx wrote:
Not looking to replace something that's missing ... looking to write
cleaner code. Something that people might look to Python for. Also,
coming from a background of procedural languages, I'm looking to learn
better techniques. Besides, I found Prolog very interesting, but none
of the tutorials I saw on the web mentions the use of Prolog in this
domain.
What about a domain-specific language, consisting of the shell commands:
shell_commands(
[
"echo a",
"echob",
"echo c"
]).
and a simple interpreter for it:
exec_commands :-
shell_commands(SCs),
exec_commands(SCs).
exec_commands([]).
exec_commands([S|Ss]) :-
( shell(S, 0) ->
exec_commands(Ss)
; format("failed."),
fail
).
Now we have:
%?- exec_commands.
%@% a
%@% sh: echob: not found
%@% failed.
%@% No
All the best,
Markus
--
comp.lang.prolog FAQ:http://www.logic.at/prolog/faq/
.
- Follow-Ups:
- Re: Prolog as a scripting language
- From: Markus Triska
- Re: Prolog as a scripting language
- References:
- Prolog as a scripting language
- From: ashley . fernandes
- Re: Prolog as a scripting language
- From: A . L .
- Re: Prolog as a scripting language
- From: ashley . fernandes
- Re: Prolog as a scripting language
- From: Markus Triska
- Prolog as a scripting language
- Prev by Date: Re: Prolog as a scripting language
- Next by Date: Re: Prolog as a scripting language
- Previous by thread: Re: Prolog as a scripting language
- Next by thread: Re: Prolog as a scripting language
- Index(es):