Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Ejercicio 4 Bernardo Lemus Daniel
objeto :- write('{'),aux1, write('}'). aux1 :- read(X),(X='atributo'->atributo; X='fin'->write('')). atributo :-read(X),write('"'),write(X),write('"'), write(':'),valorobjeto(X),aux2. valorobjeto(M):-read(Y),(Y='cadena'->cadena; Y='numero'->numero; Y='objeto'->objeto; Y='arreglo'->arreglo; Y='metodo'->metodo(M); Y='true'->verdadero; Y='false'->falso). aux2 :- read(X),(X='atributo'->write(','),atributo; X='fin'->write('')). cadena :- read(X),write('"'),write(X),write('"'). numero :- read(N),write(N). arreglo :- write('['),aux3,write(']'). aux3 :- read(X),(X='valor'->valorarreglo,aux4; X='fin'->write('')). aux4 :- read(X),(X='valor'->write(','),valorarreglo,aux4; X='fin'->write('')). valorarreglo :-read(Y),(Y='cadena'->cadena; Y='numero'->numero; Y='objeto'->objeto; Y='arreglo'->arreglo; Y='true'->verdadero; Y='false'->falso). verdadero :- write('true'). falso :- write('false'). metodo(M) :- write('"function() {'),instruccion(M), write('return '),write(M),write('}"'). instruccion(M) :- read(I),(I='asignacion'->asignacion,instruccion(M); I='decision' ->decision,instruccion(M); I='ciclo' ->ciclo(M),instruccion(M); I='fin'->write('')). ciclo(M) :- write('for(let i in obj.planta'),almacen(M), atributo2, instruccion(M), write('}'). almacen(M) :- read(X),(X='almacenA'-> Y='[0]'; X='almacenB'-> Y='[1]'), write(Y),write('.inventario){'),write(M),write('+=obj.planta'),write(Y),write('.inventario[i].'). atributo2 :- read(X), write(X), write(';'). asignacion :- read(X),write(X),write('='),read(Y),write(Y),write(';'). decision :- write('if ('),read(C),write(C),write(') {'),instruccion,write('}'),aux5. aux5 :- read(X),(X='sino'->write('else {'),instruccion,write('}'); X='fin'->write('')). :- objeto.
run
|
edit
|
history
|
help
0
00 Huhu-Dea
atributos infinitos (no completado)
2da operación
arreglos 9 sept
Arreglos Segura_Sanchez
Superqueries final
json con recursividad
codificador_arreglos_objetos
Consulta SQL
23 febrero