diff --git a/logtalk_kernel/logtalk_server/jupyter_request_handling.lgt b/logtalk_kernel/logtalk_server/jupyter_request_handling.lgt index c8a3030..0cea1f1 100644 --- a/logtalk_kernel/logtalk_server/jupyter_request_handling.lgt +++ b/logtalk_kernel/logtalk_server/jupyter_request_handling.lgt @@ -28,6 +28,8 @@ :- public(loop/3). % loop(+ContIn, +Stack, -ContOut) :- uses(term_io, [format_to_atom/3, write_term_to_atom/3]). + :- uses(user, [atomic_list_concat/2]). + :- uses(jupyter_logging, [create_log_file/1, log/1, log/2]). :- uses(jupyter_jsonrpc, [send_success_reply/2, send_error_reply/3, next_jsonrpc_message/1, parse_json_terms_request/3]). :- uses(jupyter_term_handling, [handle_term/6, term_response/1]). @@ -272,8 +274,7 @@ ; Goal = Goal0 ), !, - user::atomic_list_concat(['print_table(', Goal, ').'], Rest). - + atomic_list_concat(['print_table(', Goal, ').'], Rest). goal_cell_magic(Code, Rest) :- atom_concat('@tree\n', Term0, Code), ( sub_atom(Term0, _, 1, 0, '.') -> @@ -281,6 +282,6 @@ ; Term = Term0 ), !, - user::atomic_list_concat(['show_term(', Term, ').'], Rest). + atomic_list_concat(['show_term(', Term, ').'], Rest). :- end_object. diff --git a/notebooks/LogtalkTutorial.ipynb b/notebooks/LogtalkTutorial.ipynb index 371efba..9f64fbc 100644 --- a/notebooks/LogtalkTutorial.ipynb +++ b/notebooks/LogtalkTutorial.ipynb @@ -45,7 +45,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/lists.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/lists.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -192,7 +192,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/scopes.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/scopes.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -327,9 +327,9 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/lists.lgt compiled ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/lists.lgt compiled ]\n", "% Redefining object lists\n", - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/lists.lgt reloaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/lists.lgt reloaded ]\n", "% (0 warnings)" ] }, @@ -386,7 +386,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/stack.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/stack.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -437,7 +437,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/clyde.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/clyde.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -482,7 +482,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/fred.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/fred.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -588,7 +588,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/foo.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/foo.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -649,7 +649,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 18, "id": "4176fb68-ec74-488f-b95b-303c3ae12bbf", "metadata": { "vscode": { @@ -683,7 +683,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 19, "id": "950e5328-610c-448c-bb2d-32703f0a0f5e", "metadata": { "vscode": { @@ -694,7 +694,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/classes.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/classes.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -758,7 +758,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 20, "id": "26d73fc7-ed03-4efc-acc9-bcc658ee11e4", "metadata": { "vscode": { @@ -782,7 +782,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 21, "id": "30e905e5-e42a-4dfe-825a-bb7fcde37ac1", "metadata": { "vscode": { @@ -806,7 +806,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 22, "id": "4da8a9df-216c-4247-8a8e-b9eb0147e4b6", "metadata": { "vscode": { @@ -830,7 +830,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 23, "id": "be4cc5d5-03b6-4a5e-b9bb-7abb79a76447", "metadata": { "vscode": { @@ -864,7 +864,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 24, "id": "bbe5028b-c2aa-449c-8f4f-7549c03ad2d3", "metadata": { "vscode": { @@ -875,7 +875,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/categories.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/categories.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -956,7 +956,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 25, "id": "cf5623ec-762b-45d0-b0d2-39fc38facdb6", "metadata": { "vscode": { @@ -1001,7 +1001,8 @@ } ], "source": [ - "jupyter::print_table(sedan::current_predicate(Predicate))." + "@table\n", + "sedan::current_predicate(Predicate)." ] }, { @@ -1016,7 +1017,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 26, "id": "ded505fc", "metadata": { "vscode": { @@ -1027,7 +1028,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/buggy.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/buggy.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -1068,7 +1069,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 27, "id": "46b07f1e", "metadata": { "vscode": { @@ -1109,7 +1110,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 28, "id": "80516dff", "metadata": { "vscode": { @@ -1120,7 +1121,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/patch.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/patch.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -1159,7 +1160,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 29, "id": "007e95de", "metadata": { "vscode": { @@ -1204,7 +1205,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 30, "id": "40ce66aa", "metadata": { "vscode": { @@ -1215,7 +1216,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/circles.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/circles.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -1262,7 +1263,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 31, "id": "f82d8e6c", "metadata": { "vscode": { @@ -1294,7 +1295,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 32, "id": "4686ad32", "metadata": { "vscode": { @@ -1305,8 +1306,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/user.lgt compiled ]\n", - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/user.lgt reloaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/user.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -1343,7 +1343,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 33, "id": "163d825f", "metadata": { "vscode": { @@ -1379,7 +1379,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 34, "id": "c491b2d4", "metadata": { "vscode": { @@ -1390,7 +1390,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/tracer.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/tracer.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -1436,7 +1436,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 35, "id": "23276d59", "metadata": { "vscode": { @@ -1460,7 +1460,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 36, "id": "4eeaa7f6", "metadata": { "vscode": { @@ -1470,42 +1470,19 @@ "outputs": [ { "data": { + "text/markdown": [ + "X | \n", + ":- | \n", + "1 | \n", + "2 | \n", + "3 | " + ], "text/plain": [ - "call: list <-- member(_58360,[1,2,3]) from user\n", - "exit: list <-- member(1,[1,2,3]) from user" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "\u001b[1mX = 1" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "list::member(X, [1,2,3])." - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "id": "c046a23d", - "metadata": { - "vscode": { - "languageId": "logtalk" - } - }, - "outputs": [ - { - "data": { - "text/plain": [ - "exit: list <-- member(2,[1,2,3]) from user" + "X | \n", + ":- | \n", + "1 | \n", + "2 | \n", + "3 | " ] }, "metadata": {}, @@ -1514,31 +1491,12 @@ { "data": { "text/plain": [ - "\u001b[1mX = 2" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "retry." - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "id": "9871f15c", - "metadata": { - "vscode": { - "languageId": "logtalk" - } - }, - "outputs": [ - { - "data": { - "text/plain": [ - "exit: list <-- member(3,[1,2,3]) from user" + "call: jupyter_term_handling <-- findall_results_and_var_names(list::member(_17410,[1,2,3]),['X'=_17410],_18482,_18484) from user\n", + "call: list <-- member(_17410,[1,2,3]) from jupyter_term_handling\n", + "exit: list <-- member(1,[1,2,3]) from jupyter_term_handling\n", + "exit: list <-- member(2,[1,2,3]) from jupyter_term_handling\n", + "exit: list <-- member(3,[1,2,3]) from jupyter_term_handling\n", + "exit: jupyter_term_handling <-- findall_results_and_var_names(list::member(_17410,[1,2,3]),['X'=_17410],[['1'],['2'],['3']],['X']) from user" ] }, "metadata": {}, @@ -1547,7 +1505,7 @@ { "data": { "text/plain": [ - "\u001b[1mX = 3" + "\u001b[1mtrue" ] }, "metadata": {}, @@ -1555,7 +1513,8 @@ } ], "source": [ - "retry." + "@table\n", + "list::member(X, [1,2,3])." ] }, { @@ -1570,7 +1529,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 37, "id": "7617a38e", "metadata": { "vscode": { @@ -1604,7 +1563,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 38, "id": "d2d0818d", "metadata": { "vscode": { @@ -1638,7 +1597,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 39, "id": "c313eb4a", "metadata": { "vscode": { @@ -1670,7 +1629,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 40, "id": "76269f41", "metadata": { "vscode": { @@ -1708,7 +1667,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 41, "id": "a2d08674", "metadata": { "vscode": { @@ -1719,7 +1678,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/my_macros.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/my_macros.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -1760,7 +1719,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 42, "id": "1380fe7c", "metadata": { "vscode": { @@ -1771,7 +1730,7 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/source.lgt loaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/source.lgt loaded ]\n", "% (0 warnings)" ] }, @@ -1803,7 +1762,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 43, "id": "c6db4e4d", "metadata": { "vscode": { @@ -1814,9 +1773,9 @@ { "data": { "text/plain": [ - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/source.lgt compiled ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/source.lgt compiled ]\n", "% Redefining object source\n", - "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/source.lgt reloaded ]\n", + "% [ /Users/pmoura/Documents/Logtalk/logtalk-jupyter-kernel/notebooks/source.lgt reloaded ]\n", "% (0 warnings)" ] }, @@ -1839,7 +1798,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 44, "id": "96a9efe2", "metadata": { "vscode": { @@ -1878,7 +1837,8 @@ } ], "source": [ - "jupyter::print_table(source::bar(X))." + "@table\n", + "source::bar(X)." ] }, {