<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Projects on nagg.eu</title><link>https://nagg.eu/projects/</link><description>Recent content in Projects on nagg.eu</description><generator>Hugo</generator><language>en</language><lastBuildDate>Fri, 02 Nov 2018 00:00:00 +0000</lastBuildDate><atom:link href="https://nagg.eu/projects/index.xml" rel="self" type="application/rss+xml"/><item><title>Altcoin Prices :: Android</title><link>https://nagg.eu/projects/altcoin-prices/</link><pubDate>Fri, 02 Nov 2018 00:00:00 +0000</pubDate><guid>https://nagg.eu/projects/altcoin-prices/</guid><description>&lt;p&gt;Altcoin Prices is the one and only free as in freedoms cryptocurrencies
portfolio tracker app for android.&lt;br&gt;
Find out more at: &lt;a href="https://altcoinprices.nagg.eu"&gt;altcoinprices.nagg.eu&lt;/a&gt;&lt;/p&gt;</description></item><item><title>AMD Ryzen-info :: Python</title><link>https://nagg.eu/projects/amd-ryzen-info/</link><pubDate>Fri, 30 Jun 2017 16:57:46 +0000</pubDate><guid>https://nagg.eu/projects/amd-ryzen-info/</guid><description>&lt;p&gt;AMD Ryzen-info is a small Python script I wrote to monitor the main hardware system information of an AMD Ryzen system running on a recent version of Linux kernel.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://gitlab.com/cfabio/Ryzen-info/raw/master/screenshot.png" alt="ryzen-info"&gt;&lt;/p&gt;
&lt;p&gt;It relies on dmidecode and lm_sensors to gather the needed information, to get correct voltage and temperature readings it is critical that the most up to date version of the it87 kernel module is installed; Python version 3.5 or higher is also hard requirement.&lt;br&gt;
Edit /etc/sysconfig/lm_sensors to make it load it87 modules at boot:&lt;/p&gt;</description></item><item><title>Monitor hard disk SMART status :: Python</title><link>https://nagg.eu/projects/monitor-hard-disk-smart-status-python/</link><pubDate>Sun, 05 Mar 2017 11:48:21 +0000</pubDate><guid>https://nagg.eu/projects/monitor-hard-disk-smart-status-python/</guid><description>&lt;p&gt;I have been fighting for years with smartd but I really never managed to configure
it the way I want.&lt;br&gt;
While I certainly am not backblaze, I still have quite a few hard disks I would
like to monitor and be able to replace before they actually die.&lt;br&gt;
I hacked up a small Python script to query some SMART attributes and send me an
email in case something funky is going on; to use it just put in /etc/cron.daily
and tell cronie to run it.&lt;br&gt;
To work correctly the script also needs &lt;code&gt;smartctl&lt;/code&gt; and &lt;code&gt;sendmail&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Pi-greco - Chudnovsky :: C</title><link>https://nagg.eu/projects/pi-greco-chudnovsky-c/</link><pubDate>Mon, 13 Aug 2012 14:07:17 +0000</pubDate><guid>https://nagg.eu/projects/pi-greco-chudnovsky-c/</guid><description>&lt;p&gt;While being a big fan of Python I am also in the continuous pursuit of better
performance.&lt;br&gt;
Like it or not, but when seeking for better performance in many cases you have
to put away high level framework/programming-languages and go back to basic;
many times basic means good old C.&lt;br&gt;
After having developed some different Python scripts to calculate the Pi-greco
up to a given number of digits (later I will post the most advanced version I
came up with) I decided it was time to make a step forward and write it in C.&lt;br&gt;
Because I am still away from home this time the test machine instead of being
the usual FX-8120 is my Lenovo Thinkpad equipped with a 2.1 GHz 2C4T 3 MB of L3
cache i3-2310M.&lt;br&gt;
On Windows the most known C (it also has a C++ wrapper) library for arbitrary
precision math is &lt;!-- raw HTML omitted --&gt;MPIR&lt;!-- raw HTML omitted --&gt;.&lt;br&gt;
One of the most important &amp;ldquo;features&amp;rdquo; of the library is that it is written in
both C and Assembly, they also provide different versions of the Assembly code,
so you can use the one that is specifically written for the CPU architecture of
the machine you will run your program on.&lt;br&gt;
The full source code of the library can be downloaded, modified and compiled by
the user to better suit his needs.&lt;br&gt;
The only downside is that the super optimized Assembly code included in the
latest stable release of the library ins&amp;rsquo;t really up to date, in fact there
still is no support for Sandy Bridge and AMD Bulldozer CPUs.&lt;br&gt;
Anyway I think no one should complain about it, MPIR is an open source project so
we can wait for an official release with the added features or get our hands
dirty and write the code we need by ourselves.&lt;br&gt;
Since I am lazy I will wait for the official team to realease the updated
Assembly; since then I can live with the current stuff.&lt;br&gt;
Talking about &amp;ldquo;current stuff&amp;rdquo; I have noticed that AMD K10 library&amp;rsquo;s version is
much faster than P4, C2D and Nehalem ones even if I am using an Intel Sandy
Bridge CPU; and I am not talking about 2-3% faster but 15-20%.&lt;br&gt;
Anyway, while the Python - I have the feeling that there still something left
here and there, tho I don&amp;rsquo;t think I can make it as fast as the C implementation
is - script (which uses GMPY2) requires 30+ seconds to compute one million
digits the program written in C takes only 1.4 seconds to complete the same task.&lt;br&gt;
Both programs use the same algorithm: Chudnovsky brothers formula&lt;/p&gt;</description></item><item><title>Clausify :: Prolog</title><link>https://nagg.eu/projects/clausify-prolog/</link><pubDate>Sat, 16 Jun 2012 08:57:56 +0000</pubDate><guid>https://nagg.eu/projects/clausify-prolog/</guid><description>&lt;p&gt;For the same exam in which I had to do the LISP project I also had to write a
Clausify program in Prolog.&lt;br&gt;
Long story short: the goal was to translate a &lt;code&gt;well formed form  (WFF or FBF in italian)&lt;/code&gt; of a first order logic language in a
&lt;code&gt;conjunctive normal form (CNF)&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;congiunzione(and).
disgiunzione(or).
negazione(not).
implicazione(implies).
esiste(exist).
per_ogni(every).

fbf2cnf(FBF, CNFFBF):- atomic(FBF),
					 CNFFBF = FBF,
					 !.
fbf2cnf(FBF, CNFFBF):- FBF =.. [X|ListaArgs],
					 semplifica([X|ListaArgs], [], CNFFBF_3_p),
					 semplifica_2(CNFFBF_3_p, [], CNFFBF_4_p),
					 controlla_lista(CNFFBF_4_p, [], CNFFBF_2_p),
					 CNFFBF_2_p =.. [M|Ms],
					 controlla_lista([M|Ms], [], CNFFBF_2),
					 CNFFBF_2 =.. [Y|Ys],
					 semplifica([Y|Ys], [], CNFFBF_3),
					 semplifica_2(CNFFBF_3, [], CNFFBF_4),
					 CNFFBF_R_P =.. CNFFBF_4,
					 not(confronta(CNFFBF_2_p, CNFFBF_2)),
					 fbf2cnf(CNFFBF_R_P, CNFFBF),
					 !.
fbf2cnf(FBF, CNFFBF):- FBF =.. [X|ListaArgs],
					 semplifica([X|ListaArgs], [], CNFFBF_3_p),
					 semplifica_2(CNFFBF_3_p, [], CNFFBF_4_p),
					 controlla_lista(CNFFBF_4_p, [], CNFFBF_2_p),
					 CNFFBF_2_p =.. [M|Ms],
					 controlla_lista([M|Ms], [], CNFFBF_2),
					 CNFFBF_2 =.. [Y|Ys],
					 semplifica([Y|Ys], [], CNFFBF_3),
					 semplifica_2(CNFFBF_3, [], CNFFBF_4),
					 CNFFBF =.. CNFFBF_4,
					 !.

confronta(CNFFBF, CNFFBF).	

semplifica([], CNFFBF_R, CNFFBF_R).
semplifica([Y|Ys], CNFFBF, CNFFBF_R):- var(Y),
									 append(CNFFBF, [Y], CNFFBF_1),
									 semplifica(Ys, CNFFBF_1, CNFFBF_R),
									 !.
semplifica([Y|Ys], CNFFBF, CNFFBF_R):- congiunzione(Y),
									 togli_and(Ys, CNFFBF, CNFFBF_1),
									 append([Y], CNFFBF_1, CNFFBF_R).
semplifica([Y|Ys], CNFFBF, CNFFBF_R):- compound(Y),
									 Y =.. [Z|Zs],
									 semplifica([Z|Zs], [], CNFFBF_1),
									 semplifica(Ys, [], CNFFBF_2),
									 R1 =.. CNFFBF_1,
									 append(CNFFBF, [R1], CNFFBF_3),
									 append(CNFFBF_3, CNFFBF_2, CNFFBF_R),
								 !.
semplifica([Y|Ys], CNFFBF, CNFFBF_R):- append(CNFFBF, [Y], CNFFBF_1),
									 semplifica(Ys, [], CNFFBF_2),
									 append(CNFFBF_1, CNFFBF_2, CNFFBF_R),
									 !.

semplifica_2([], CNFFBF_R, CNFFBF_R).
semplifica_2([Y|Ys], CNFFBF, CNFFBF_R):- var(Y),
										 append(CNFFBF, [Y], CNFFBF_1),	
									 semplifica_2(Ys, CNFFBF_1, CNFFBF_R),
									 !.
semplifica_2([Y|Ys], CNFFBF, CNFFBF_R):- disgiunzione(Y),
									 togli_or(Ys, CNFFBF, CNFFBF_1),
									 append([Y], CNFFBF_1, CNFFBF_R).
semplifica_2([Y|Ys], CNFFBF, CNFFBF_R):- compound(Y),
									 Y =.. [Z|Zs],
									 semplifica_2([Z|Zs], [], CNFFBF_1),
									 semplifica_2(Ys, [], CNFFBF_2),
									 R1 =.. CNFFBF_1,
									 append(CNFFBF, [R1], CNFFBF_3),
									 append(CNFFBF_3, CNFFBF_2, CNFFBF_R),
								 !.
semplifica_2([Y|Ys], CNFFBF, CNFFBF_R):- append(CNFFBF, [Y], CNFFBF_1),
									 semplifica_2(Ys, [], CNFFBF_2),
									 append(CNFFBF_1, CNFFBF_2, CNFFBF_R),
									 !.

togli_and([], CNFFBF_R, CNFFBF_R).
togli_and([Y|Ys], CNFFBF, CNFFBF_R):- Y =.. [Z|Zs],
									 congiunzione(Z),
									 togli_and(Zs, CNFFBF, CNFFBF_1),
									 togli_and(Ys, CNFFBF_1, CNFFBF_R),
									 !.
togli_and([Y|Ys], CNFFBF, CNFFBF_R):- append(CNFFBF, [Y], CNFFBF_1),
									 togli_and(Ys, CNFFBF_1, CNFFBF_R),
									 !.

togli_or([], CNFFBF_R, CNFFBF_R).
togli_or([Y|Ys], CNFFBF, CNFFBF_R):- Y =.. [Z|Zs],
									 disgiunzione(Z),
									 togli_or(Zs, CNFFBF, CNFFBF_1),
									 togli_or(Ys, CNFFBF_1, CNFFBF_R),
									 !.
togli_or([Y|Ys], CNFFBF, CNFFBF_R):- append(CNFFBF, [Y], CNFFBF_1),
									 togli_or(Ys, CNFFBF_1, CNFFBF_R),
									 !.

%% lista vuota
controlla_lista([], CNFFBF_R, CNFFBF_R).
%% trova and
controlla_lista([X|ListaArgs], CNFFBF, CNFFBF_R):- congiunzione(X),
							count_elements(ListaArgs, N),
							N &amp;amp;gt;= 2,
							costruisci_and(ListaArgs, CNFFBF, CNFFBF_1),
							CNFFBF_R =.. [X|CNFFBF_1],
							!.
%% controllare se or (... and)
controlla_lista([X|ListaArgs], CNFFBF, CNFFBF_R):- disgiunzione(X),
								count_elements(ListaArgs, N),
								N &amp;amp;gt;= 2,
								cerca_and(ListaArgs),
								estrai_parametri(ListaArgs, [], Lista_AND),
								costruisci_or_and(Lista_AND, [], CNFFBF_R1),
								append(CNFFBF, CNFFBF_R1, CNFFBF_R2),
								CNFFBF_R =.. [&amp;#39;and&amp;#39;|CNFFBF_R2],
								!.

%% trova or
controlla_lista([X|ListaArgs], CNFFBF, CNFFBF_R):- disgiunzione(X),
								count_elements(ListaArgs, N),
								N &amp;amp;gt;= 2,
								costruisci_or(ListaArgs, [], CNFFBF_1),
								append(CNFFBF, CNFFBF_1, CNFFBF_2),
								CNFFBF_R =.. [X|CNFFBF_2],
								!.
%% trova not di not
controlla_lista([X,X1|ListaArgs], CNFFBF, CNFFBF_R):- negazione(X),
								X1 =.. [Y,Y1|Ys],
								count_elements(Ys, M),
								M = 0,
								count_elements(ListaArgs, N),
								N = 0,
								negazione(Y),
								costruisci_not(Y1, CNFFBF, CNFFBF_R),
								!.
%% trova not di atomo
controlla_lista([X,X1|ListaArgs], CNFFBF, CNFFBF_R):- negazione(X),
								count_elements(ListaArgs, N),	
								N = 0,
								atomic(X1),
								CNFFBF_1 =.. [X|[X1]],
								append(CNFFBF, CNFFBF_1, CNFFBF_R),
								!. 
%% CASO #1 : not (and (p, q)) = or (not (p), not (q))
controlla_lista([X,X1|ListaArgs], CNFFBF, CNFFBF_R):- negazione(X),	
								count_elements(ListaArgs, N),
								N = 0,
								compound(X1),	
								X1 =.. [Y|Ys],
								congiunzione(Y),	
								costruisci_not_and(Ys, CNFFBF, CNFFBF_1),
								CNFFBF_R =.. [&amp;#39;or&amp;#39;|CNFFBF_1],	
								!.
%% CASO #2 : not (or (p, q)) = and (not (p), not (q))
controlla_lista([X,X1|ListaArgs], CNFFBF, CNFFBF_R):- negazione(X),	
								count_elements(ListaArgs, N),	
								N = 0,
								compound(X1),
								X1 =.. [Y|Ys],
								disgiunzione(Y),
								costruisci_not_or(Ys, CNFFBF, CNFFBF_1),
								CNFFBF_R =.. [&amp;#39;and&amp;#39;|CNFFBF_1],
								!.
%% not(every) # not(exist(X, p(X))) = every(X, not(P(X)))
controlla_lista([X,X1|ListaArgs], CNFFBF, CNFFBF_R):- negazione(X),
								count_elements(ListaArgs, N),	
								N = 0,
								X1 =.. [Y,V,F|Ys],
								count_elements(Ys, M),
								M = 0,
								esiste(Y),
								CNFFBF_F =.. [&amp;#39;not&amp;#39;|[F]],	
								append([V], [CNFFBF_F], CNFFBF_1),
								CNFFBF_2 =.. [&amp;#39;every&amp;#39;|CNFFBF_1],
								CNFFBF_2 =.. [Z|Zs],
								controlla_lista([Z|Zs], [], CNFFBF_R),
								!.
%% not(every) # not(every(X, p(X))) = exist(X, not(P(X)))
controlla_lista([X,X1|ListaArgs], CNFFBF, CNFFBF_R):- negazione(X),
								count_elements(ListaArgs, N),
								N = 0,
								X1 =.. [Y,V,F|Ys],
								count_elements(Ys, M),
								M = 0,
								per_ogni(Y),
								CNFFBF_F =.. [&amp;#39;not&amp;#39;|[F]],
								append([V], [CNFFBF_F], CNFFBF_1),
								CNFFBF_2 =.. [&amp;#39;exist&amp;#39;|CNFFBF_1],
								CNFFBF_2 =.. [Z|Zs],
								controlla_lista([Z|Zs], [], CNFFBF_R),
								!.
%% trova un implies # implies(P, Q) = or(not(P), Q)
controlla_lista([X,P,Q|ListaArgs], CNFFBF, CNFFBF_R):- implicazione(X),
								count_elements(ListaArgs, N),
								N = 0,
								costruisci_implicazione(P, Q, CNFFBF_R),
													 !.
%% trova un exist # exist(Y, every(Y,p(X,Y))) = every(Y, p(sf666(Y), Y))
controlla_lista([X,V,F|ListaArgs], CNFFBF, CNFFBF_R):- esiste(X),
								count_elements(ListaArgs, N),
								N = 0,
								var(V),
								F =.. [Y,V1,F1|Ys],
								count_elements(Ys, M),
								M = 0,
								per_ogni(Y),
								skolem_function([V],SF).
%% trova un exist # exist(X, p(X)) = p(skv+numero)
controlla_lista([X,V,F|ListaArgs], CNFFBF, CNFFBF_R):- esiste(X),
								count_elements(ListaArgs, N),
								N = 0,
								var(V),
								skolem_function(SK, V),
								F =.. [Y|Ys],
								controlla_lista([Y|Ys], [], CNFFBF_R),
								!.
%% trova un every # every(X, p(X)) = p(skv+numero)
controlla_lista([X,V,F|ListaArgs], CNFFBF, CNFFBF_R):- per_ogni(X),
								count_elements(ListaArgs, N),
								N = 0,
								var(V),
								skolem_function(SK, V),
								F =.. [Y|Ys],
								controlla_lista([Y|Ys], [], CNFFBF_R),
								!.
%% trova un predicato
controlla_lista([X|Xs], CNFFBF, CNFFBF_R):- count_elements(Xs, N),
								N &amp;amp;gt;= 1,
								controlla_predicato([X|Xs], CNFFBF, [Y|Ys]),
								CNFFBF_R =.. [Y|Ys],
								!.

%% trovato un predicato, controlla i suoi elementi
controlla_predicato([], CNFFBF_R, CNFFBF_R).
controlla_predicato([X|Xs], CNFFBF, CNFFBF_R):- atomic(X),
								append(CNFFBF, [X], CNFFBF_1),
								controlla_predicato(Xs, CNFFBF_1, CNFFBF_R),
								!.
controlla_predicato([X|Xs], CNFFBF, CNFFBF_R):- compound(X),
								X =.. [Y|Ys],
								controlla_lista([Y|Ys], [], CNFFBF_1),
								append(CNFFBF, [CNFFBF_1], CNFFBF_2),
								controlla_predicato(Xs, CNFFBF_2, CNFFBF_R),
								!.

%% trova un and, nel caso gli elementi siano atomi fa l&amp;#39;append a CNFFBF_R
%% , altrimenti richiama controlla_lista
%% elementi, lista_a_cui_aggiungere, lista_risultato
costruisci_and([], CNFFBF_R, CNFFBF_R).
costruisci_and([X|Xs], CNFFBF, CNFFBF_R):- atomic(X),
								append(CNFFBF, [X], CNFFBF_1),
								costruisci_and(Xs, CNFFBF_1, CNFFBF_R),
								!.
costruisci_and([X|Xs], CNFFBF, CNFFBF_R):- compound(X),
								X =.. [Y|Ys],
								controlla_lista([Y|Ys], [], CNFFBF_R1),
								append(CNFFBF, [CNFFBF_R1], CNFFBF_R2),
								costruisci_and(Xs, CNFFBF_R2, CNFFBF_R),
										 !.

%% trova un or
costruisci_or([], CNFFBF_R, CNFFBF_R).
costruisci_or([X|Xs], CNFFBF, CNFFBF_R):- atomic(X),
								append(CNFFBF, [X], CNFFBF_1),
								costruisci_or(Xs, CNFFBF_1, CNFFBF_R),
								!.
costruisci_or([X|Xs], CNFFBF, CNFFBF_R):- compound(X),
								X =.. [Y|Ys],
								controlla_lista([Y|Ys], [], CNFFBF_R1),
								costruisci_or(Xs, [], CNFFBF_R2),
								append(CNFFBF, [CNFFBF_R1], CNFFBF_2),
								append(CNFFBF_2, CNFFBF_R2, CNFFBF_R3),
								CNFFBF_R3 =.. [Z|Zs],
								controlla_lista([Z|Zs], [], CNFFBF_R),
								!.

%% trovo un or con dentro almeno un and, allora costruisco le coppie
%% Lista_parametri_da_accoppiare, CNFFBF_parziale, CNFFBF_finale
costruisci_or_and([], CNFFBF_R, CNFFBF_R).
costruisci_or_and([X|Xs], CNFFBF, CNFFBF_R):- 
								accoppia(X, Xs, CNFFBF, CNFFBF_R1),
								costruisci_or_and(Xs, CNFFBF_R1, CNFFBF_R),
								!.

accoppia(Elem, [], CNFFBF_R, CNFFBF_R).
accoppia([], _, CNFFBF_R, CNFFBF_R).
accoppia([E|Es], [[Y|Ys]|Xs], CNFFBF, CNFFBF_R):- 
								accoppia_and(E, [Y|Ys], CNFFBF, CNFFBF_1),
								accoppia_and(E, Xs, CNFFBF_1, CNFFBF_2),
								accoppia(Es, [[Y|Ys]|Xs], CNFFBF_2, CNFFBF_R),
								!.
accoppia([E|Es], [Y|Ys], CNFFBF, CNFFBF_R):- 
								accoppia_and(E, [Y|Ys], CNFFBF, CNFFBF_1),
								elementi_lista(Es, [Y|Ys], CNFFBF_1, CNFFBF_R).
accoppia(Elem, [[Y|Ys]|Xs], CNFFBF, CNFFBF_R):- 
								append([Elem], [Y], CNFFBF_1),
								CNFFBF_2 =.. [&amp;#39;or&amp;#39;|CNFFBF_1],
								append(CNFFBF, [CNFFBF_2], CNFFBF_3),
								accoppia(Elem, [Ys|Xs], CNFFBF_3, CNFFBF_R),
								!.
accoppia(Elem, [X|Xs], CNFFBF, CNFFBF_R):- 
								accoppia(Elem, Xs, CNFFBF, CNFFBF_R),
								!.

accoppia_and(_, [], CNFFBF_R, CNFFBF_R).
accoppia_and(Elem, [[Y|Ys]|Xs], CNFFBF, CNFFBF_R):- 
								accoppia_and(Elem, [Y|Ys], CNFFBF, CNFFBF_1),
								accoppia_and(Elem, Xs, CNFFBF_1, CNFFBF_R).
accoppia_and(Elem, [Y|Ys], CNFFBF, CNFFBF_R):- append([Elem], [Y], CNFFBF_1),
								CNFFBF_2 =.. [&amp;#39;or&amp;#39;|CNFFBF_1],
								append(CNFFBF, [CNFFBF_2], CNFFBF_3),
								accoppia_and(Elem, Ys, CNFFBF_3, CNFFBF_R),
								!.

elementi_lista([], _, CNFFBF_R, CNFFBF_R).
elementi_lista([E|Es], [Y|Ys], CNFFBF, CNFFBF_R):- 
								accoppia_and(E, [Y|Ys], CNFFBF, CNFFBF_1),
								elementi_lista(Es, [Y|Ys], CNFFBF_1, CNFFBF_R).

%% estrae i parametri dell&amp;#39;or
estrai_parametri([], Lista_R, Lista_R).
estrai_parametri([X|Xs], Lista_1, Lista_R):- atomic(X),
								append(Lista_1, [X], Lista_2),
								estrai_parametri(Xs, Lista_2, Lista_R),
								!.
estrai_parametri([X|Xs], Lista_1, Lista_R):- compound(X),
								X =.. [Y|Ys],
								congiunzione(Y),
								controlla_lista([Y|Ys], [], Lista_X),
								Lista_X =.. [Z|Zs],
								estrai_parametri(Xs, [], Lista_Xs),
								append(Lista_1, [Zs], Lista_R1),
								append(Lista_R1, Lista_Xs, Lista_R),
								!.

estrai_parametri([X|Xs], Lista_1, Lista_R):- compound(X),
								 X =.. [Y|Ys],
								controlla_lista([Y|Ys], [], Lista_X),
								estrai_parametri(Xs, [], Lista_Xs),
								append(Lista_1, [Lista_X], Lista_R1),
								append(Lista_R1, Lista_Xs, Lista_R),
								!.

%% cerca se c&amp;#39;è un and
cerca_and([X|Xs]):- atomic(X),
					cerca_and(Xs),
					!.		
cerca_and([X|Xs]):- compound(X),
					X =.. [Y|Ys],
					count_elements(Ys, N),
					N &amp;amp;gt;= 2,
					congiunzione(Y),
					!.										
cerca_and([X|Xs]):- compound(X),
					X =.. [Y|Ys],
					cerca_and(Xs),
					!.

%% not è stato trovato, guarda cosa ha come parametro
costruisci_not(Y1, CNFFBF, CNFFBF_R):- atomic(Y1),
									 append(CNFFBF, Y1, CNFFBF_R),
									 !.
costruisci_not(Y1, CNFFBF, CNFFBF_R):- compound(Y1),
								Y1 =.. [Z|Zs],
								controlla_lista([Z|Zs], CNFFBF, CNFFBF_R),
								!.
costruisci_not(Y1, CNFFBF, CNFFBF_R):- Y1 =.. [X|Xs],
								negazione(X),
								controlla_lista([X|Xs], CNFFBF, CNFFBF_R),
								!.

%% trova un not che ha come parametro un and
costruisci_not_and([], CNFFBF_R, CNFFBF_R).
costruisci_not_and([X|Xs], CNFFBF, CNFFBF_R):- atomic(X),
								CNFFBF_1 =.. [&amp;#39;not&amp;#39;|[X]],
								append(CNFFBF, [CNFFBF_1], CNFFBF_2),
								costruisci_not_and(Xs, CNFFBF_2, CNFFBF_R),
								!.
costruisci_not_and([X|Xs], CNFFBF, CNFFBF_R):- compound(X),
								X =.. [Y|Ys],
								controlla_lista([Y|Ys], CNFFBF_1, CNFFBF_2),
								CNFFBF_3 =.. [&amp;#39;not&amp;#39;|[CNFFBF_2]],
								append(CNFFBF, [CNFFBF_3], CNFFBF_4),
								costruisci_not_and(Xs, CNFFBF_4, CNFFBF_R),
								!.

%% trova un not che ha come parametro un or
costruisci_not_or([], CNFFBF_R, CNFFBF_R).
costruisci_not_or([X|Xs], CNFFBF, CNFFBF_R):- atomic(X),
								CNFFBF_1 =.. [&amp;#39;not&amp;#39;|[X]],
								append(CNFFBF, [CNFFBF_1], CNFFBF_2),
								costruisci_not_or(Xs, CNFFBF_2, CNFFBF_R),
								!.	 
costruisci_not_or([X|Xs], CNFFBF, CNFFBF_R):- compound(X),
								 X =.. [Y|Ys],
								controlla_lista([Y|Ys], CNFFBF_1, CNFFBF_2),
								CNFFBF_3 =.. [&amp;#39;not&amp;#39;|[CNFFBF_2]],
								append(CNFFBF, [CNFFBF_3], CNFFBF_4),
								costruisci_not_or(Xs, CNFFBF_4, CNFFBF_R),
									!.

%% trova un implies # implies(P, Q) = or(not(P), Q)
costruisci_implicazione(P, Q, CNFFBF_R):- atomic(P),
										 atomic(Q),
										 CNFFBF_P =.. [&amp;#39;not&amp;#39;|[P]],	
										 append([CNFFBF_P], [Q], CNFFBF_1),
										 CNFFBF_R =.. [&amp;#39;or&amp;#39;|CNFFBF_1].
costruisci_implicazione(P, Q, CNFFBF_R):- atomic(P),
								compound(Q),
								CNFFBF_P =.. [&amp;#39;not&amp;#39;|[P]],
								Q =.. [Y|Ys],
								controlla_lista([Y|Ys], [], CNFFBF_Q_1),
								append([CNFFBF_P], [CNFFBF_Q_1], CNFFBF_1),
								CNFFBF_R =.. [&amp;#39;or&amp;#39;|CNFFBF_1].
costruisci_implicazione(P, Q, CNFFBF_R):- compound(P),
								atomic(Q),
								CNFFBF_P =.. [&amp;#39;not&amp;#39;|[P]],
								CNFFBF_P =.. [X|Xs],
								controlla_lista([X|Xs], [], CNFFBF_P_1),
								append([CNFFBF_P_1], [Q], CNFFBF_1),
								CNFFBF_R =.. [&amp;#39;or&amp;#39;|CNFFBF_1].
costruisci_implicazione(P, Q, CNFFBF_R):- CNFFBF_P =.. [&amp;#39;not&amp;#39;|[P]],
								CNFFBF_P =.. [X|Xs],
								controlla_lista([X|Xs], [], CNFFBF_P_1),
								Q =.. [Y|Ys],
								controlla_lista([Y|Ys], [], CNFFBF_Q_1),
								append([CNFFBF_P_1], [CNFFBF_Q_1], CNFFBF_1),
								CNFFBF_R =.. [&amp;#39;or&amp;#39;|CNFFBF_1].

skolem_variable(V, SK):- var(V), gensym(skv, SK).
skolem_function([], SF):- skolem_variable(_, SF).
skolem_function([A | ARGS], SF) :- gensym(skf, SF_op),
								 SF =.. [SF_op, A | ARGS].

%% conta gli elementi della lista
count_elements([],0).
count_elements([X|Xs],N):- count_elements(Xs,M), N is M + 1.

%%%% controlla se la FBF è clausola di Horn
horn(FBF):- atomic(FBF).
horn(FBF):- fbf2cnf(FBF, CNF),
			CNF =.. [X|Xs],
			negazione(X).
horn(FBF):- fbf2cnf(FBF, CNF),
			CNF =.. [X|Xs],
			conta(Xs, 0, N),
			N &amp;amp;lt; 2.

%%%% conta i letterali non negativi			
conta([], N, N).
conta([X|Xs], N, N):- negazione(X).
conta([X|Xs], N1, N):- compound(X),
					 X =.. [Y|Ys],
				 negazione(Y),
				 conta(Xs, 0, M),
				 N is N1 + M,
				 !.
conta([X|Xs], N1, N):- compound(X),	
 				 X =.. [Y|Ys],
				 conta(Ys, 0, M0),
				 conta(Xs, 0, M1),
				 M2 is M0 + N1,
					 N is M2 + M1,
				 !.
conta([X|Xs], N1, N):- atomic(X),
				 M1 is N1 + 1,
				 conta(Xs, 0, M),
				 N is M1 + M,
				 !.

confronta_liste([],[]).					 
confronta_liste([X|Xs],[X|Ys]):- confronta_liste(Xs, Ys),
								 !.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I think that&amp;rsquo;s all.&lt;br&gt;
Cheers.&lt;/p&gt;</description></item><item><title>Parse-URI :: LISP</title><link>https://nagg.eu/projects/parse-uri-lisp/</link><pubDate>Mon, 27 Feb 2012 22:32:33 +0000</pubDate><guid>https://nagg.eu/projects/parse-uri-lisp/</guid><description>&lt;p&gt;In the last exams session I had to write a simplified URI parser in LISP.&lt;br&gt;
LISP has the well known ability to melt people&amp;rsquo;s brain, but when you manage to
wrap your head around things it becomes quite interesting.&lt;br&gt;
The projects for this course are always quite similar, so I assume someone
could be interested to see how I did it.&lt;br&gt;
Please note that I did everything in no more than 3 or 4 hours, so surely it
could have been done better (for example without using defparameter
instructions).&lt;br&gt;
Anyway it got me a pretty high mark, so I am OK with it.&lt;br&gt;
Here is the simplified syntax I had to follow:&lt;/p&gt;</description></item><item><title>ATI Driver Tweaker :: C</title><link>https://nagg.eu/projects/ati-driver-tweaker/</link><pubDate>Sat, 17 Sep 2011 18:07:51 +0000</pubDate><guid>https://nagg.eu/projects/ati-driver-tweaker/</guid><description>&lt;p&gt;ATI Driver Tweaker is a simple program that allows the user to manage the most
important driver settings of ATI videocards.&lt;br&gt;
I wrote it because I am tired of all the others tweaking software for ATI
graphic cards, quite often they don’t work properly or make 3d programs crash.&lt;br&gt;
This program is written in pure C, doesn’t need NET framework or any other kind
of crap, doesn’t need to be installed and works on Windows XP, Vista and Seven
(both x86 and x64 versions)&lt;/p&gt;</description></item></channel></rss>