I have this prolog code:
libro(autor('Chomsky', 'Noah'),
titulo('Aspectos de la Teoría de la sintaxis'),
editorial('Madrid', 'Aguilar'),
fecha(1970)).
libro(autor('Matthews', 'P'),
titulo('Inflectional Morphology'),
editorial('Cambridge', 'Cambridge University Press'),
fecha(1972)).
libro(autor('Chomsky', 'Noah'),
titulo('Estructuras sintácticas'),
editorial('Mexico', 'Siglo XXI'),
fecha(1974)).
I need to find all books written by Chomsky (in my case). What is the rutine to obtain them?
Thank You
You just need to match on the pattern autor('Chomsky',_) as below:
?- libro(autor('Chomsky',_),T,E,Y).
T = titulo('Aspectos de la Teoría de la sintaxis'),
E = editorial('Madrid', 'Aguilar'),
Y = fecha(1970) ;
T = titulo('Estructuras sintácticas'),
E = editorial('Mexico', 'Siglo XXI'),
Y = fecha(1974).
You need to type a semicolon to fetch the next result.
You could also use findall to get all results as a list, for example:
?- findall(libro(T,E,Y),libro(autor('Chomsky',_),T,E,Y),R).
R = [libro(titulo('Aspectos de la Teoría de la sintaxis'), editorial('Madrid', 'Aguilar'), fecha(1970)), libro(titulo('Estructuras sintácticas'), editorial('Mexico', 'Siglo XXI'), fecha(1974))].
Related
I am making a program that calculates the percentage of males and females in the class. But it gives me an incorrect result.
The code is:
package main
import {
"fmt"
}
var total, mujeres, hombres float64
func main() {
fmt.Printf("Número de mujeres:")
fmt.Scanln(&mujeres)
fmt.Printf("Número de hombres:")
fmt.Scanln(&hombres)
total = mujeres + hombres
mujeres = (mujeres / total) * 100
hombres = (hombres / total) * 100
print("En al salón de clases hay ", mujeres, "% de mujeres y ",
hombres, "% de hombres")
}
And the output I'm getting when entering 50 for both quantities is:
En al salón de clases hay +5.000000+001% de mujeres y +5.000000+001% de hombres
I want to know what causes this problem and how to solve it.
It's not giving an incorrect result, it's giving the correct result in an incorrect format. The value +5.000000e+001 is 5x101, which is equal to 50.
If you want them formatted differently to the default, you need to specify that, such as with:
fmt.Printf("En al salón de clases hay %.1f%% du mujeres y %.1f%% du hombres\n",
mujeres, hombres)
I m trying to replace a string "::" on a plain text for <b> or </b>. Depending of the first or second match without result with sed. The goal here is that the second tag </b> can be at the end of a paragraph not at the end of a line. i.e:
::Habiéndose calmado de distracciones, uno permanece completamente,
y la naturaleza superior es vista con los ojos de la sabiduría.::
must be
<b>Habiéndose calmado de distracciones, uno permanece completamente,
y la naturaleza superior es vista con los ojos de la sabiduría.</b>
I try it without result:
sed "s|::\(.*\)|\\<b>\1\</b>|g" EntrenamientoProgresivoSamadhi
Thank you in Advantage
Assumptions:
:: can occur more than once on a given line of input
:: never shows up as data (ie, we need to replace all occurrences of ::)
a solution using awk is acceptable
Adding some more data to our input:
$ cat file
::Habiéndose calmado de distracciones, uno permanece completamente,
y la naturaleza superior es vista con los ojos de la sabiduría.::
some more ::text1:: and then some more ::text2:: the end
One awk idea:
awk '
BEGIN { tag[0]="<b>"; tag[1]="</b>" }
{ while (sub(/::/,tag[c%2])) c++; print }
' file
This generates:
<b>Habiéndose calmado de distracciones, uno permanece completamente,
y la naturaleza superior es vista con los ojos de la sabiduría.</b>
some more <b>text1</b> and then some more <b>text2</b> the end
Using GNU sed
$ sed -Ez 's~::(.[^:]*)::~<b>\1</b>~' input_file
<b>Habiéndose calmado de distracciones, uno permanece completamente,
y la naturaleza superior es vista con los ojos de la sabiduría.</b>
Use awk and increment a counter variable. Then you can perform a different substitution depending on whether it's odd or event.
awk '/::/ && counter++ % 2 == 0 {sub("::", "<b>") }
/::/ {sub("::", "</b>") }
1'
Note that this will only work correctly if the start and end :: are on different lines.
This might work for you (GNU sed):
sed ':a;/::/{x;s/^/x/;/xx/{s///;x;s/::/<\/b>/;ba};x;s/::/<b>/;ba}' file
If a line contains ::, swap to the hold space and increment a counter by inserting an x at the start of the line.
If the counter is 2 i.e. the swap space contains xx, reset the counter and then swap back to the pattern space and replace :: by <\b> and go again (in the case that a line contains 2 or more :: strings).
Otherwise, swap back to the pattern space and replace :: by <b and go again (for reasons explained above).
All other lines are untouched.
Possible query a laravel query builder,lo que trato de hacer son las operaciones para calcular el descuto salarial de un dia faltado y si cuenta con prestamo tambien descontarlo
select empleado.sueldo_inci,empleado.sal_diario,
((empleado.sueldo_inci-empleado.sal_diario)-Prestamo.descuento)
as final,Prestamo.descuento from empleado
inner join Prestamo on empleado.idemp=1
\DB::table('empleado')
->join('prestamo', 'empleado.id', 'prestado.empleado_id')
->select(['empleado.sueldo_inci', 'empleado.sal_diario', 'prestamo.descuento'])
->selectRaw('(empleado.sueldo_inci - empleado.sal_diario - prestamo.descuento) AS final')
->get()
In order to set the color of a batch script's console/terminal, color can be used. E.g. color 70. However, in order to reset the color of a the console, color without any arguments/values can be used. What is causing confusion for me is why it only works inside the command prompt or a called script but not a script started specifically with cmd /c. It fails and returns an errorcode of 1. Is there some legacy reason for this or is it a bug in Windows?
cmd /c color || echo foobar
Output: foobar
Expected output:
cmd /c color 70 || echo foobar
Output:
Expected output:
call color || echo foobar
Output:
Expected output:
To have no error, try to put the default color, as you said,
the color of a the console
That means the default color, I gess, so put color 07, to switch to color black-light grey.
For more info for colors in a .bat file create a .bat file and put in it color h, only this, save it and run it. It will give you all the info about colors.
If you are not able to do this, here is what it will show you. (Sorry, it's in french, but I gess you can understand)
Change les couleurs par défaut du premier et de l'arrière plan de la console.
COLOR [attr]
attr Spécifie les attributs de couleurs de l'apparence de la console
Les attributs de couleurs sont spécifiés par DEUX chiffres hexadécimaux -- le
premier correspond à l'arrière plan, le second au premier plan. Chaque chiffre
peut prendre n'importe quelle de ces valeurs :
0 = Noir 8 = Gris
1 = Bleu foncé 9 = Bleu clair
2 = Vert A = Vert clair
3 = Bleu-gris B = Cyan
4 = Marron C = Rouge
5 = Pourpre D = Rose
6 = Kaki E = Jaune
7 = Gris clair F = Blanc
Si aucun argument n'est donné, cette commande restaure les couleurs
sélectionnées au moment où CMD.EXE a été ouvert. Cette valeur vient soit de la
fenêtre de la console, du commutateur en ligne de commande /T, ou de la valeur
DefaultColor du registre.
Appuyez sur une touche pour continuer...
Again, sorry that is in french
Kalolol
I need a php script that convert certain special characters to ascii code( , . / - and all the letter with accent)
eg.
original:
Dingo a accidentellement fait tomber la pièce porte-bonheur de Mickey tout au fond du lac. Le Professeur Von Drake va utiliser son camping-car et le transformer en sous-marin pour explorer les eaux profondes.
result:
Dingo a accidentellement fait tomber la pièce porte-bonheur de Mickey tout au fond du lac. Le Professeur Von Drake va utiliser son camping-car et le transformer en sous-marin pour explorer les eaux profondes.
I've tried htmlspecialchars() doesn't seems work out it only convert the characters which are special significance in HTML
If you look at the documentation of htmlspecialchars() you will see:
If you require all input substrings that have associated named entities to be translated, use htmlentities() instead.