Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- true.
- baseKB: ?- repl.
- __ ___ __ __ ____ _
- \ \ / / \ | \/ | / ___| |
- \ \ /\ / / _ \ | |\/| |_____| | | |
- \ V V / ___ \| | | |_____| |___| |___
- \_/\_/_/ \_\_| |_| \____|_____|
- Common Lisp, written in Prolog
- ```
- ```cl
- CL-USER> (defun nconc (&optional lst &rest rest)
- CL-USER>>> (if rest
- CL-USER>>> (let ((rest-conc (apply #'nconc rest)))
- CL-USER>>> (if (consp lst)
- CL-USER>>> (progn (setf (cdr (last lst)) rest-conc)
- CL-USER>>> lst)
- CL-USER>>> rest-conc))
- CL-USER>>> lst))
- ```
- ```prolog
- :- lisp_compiled_eval(
- [ defun,
- nconc,
- [c38_optional, u_lst, c38_rest, rest],
- [ if,
- rest,
- [ let,
- [[u_rest_conc, [apply, function(nconc), rest]]],
- [ if,
- [consp, u_lst],
- [ progn,
- [setf, [cdr, [last, u_lst]], u_rest_conc],
- u_lst
- ],
- u_rest_conc
- ]
- ],
- u_lst
- ]
- ]).
- ## COMPILER
- :- side_effect((compile_each([name='GLOBAL', environ=env_1], LEnv, [], [], true), append([[last, u_lst]], [CAR21, CAR], [[last, u_lst], CAR21, CAR]), setf_inverse_op(cdr, rplacd))).
- :- side_effect((compile_each([name='GLOBAL', environ=env_1], LEnv, [], [], true), append([[last, u_lst]], [CAR21, CAR], [[last, u_lst], CAR21, CAR]), setf_inverse_op(cdr, rplacd))).
- % 649,509 inferences, 0.133 CPU in 0.135 seconds (99% CPU, 4880732 Lips)
- lambda_def(defun, nconc, f_nconc, [c38_optional, u_lst, c38_rest, rest], [[if, rest, [let, [[u_rest_conc, [apply, function(nconc), rest]]], [if, [consp, u_lst], [progn, [setf, [cdr, [last, u_lst]], u_rest_conc], u_lst], u_rest_conc]], u_lst]]).
- arglist_info(nconc, f_nconc, [c38_optional, u_lst, c38_rest, rest], arginfo{all:[u_lst], allow_other_keys:0, aux:0, body:0, complex:[opt, rest], env:0, key:0, names:[u_lst, rest], opt:[u_lst], outer:ReplEnv, req:0, rest:[rest], sublists:0, whole:0}).
- init_args(0, f_nconc).
- ```
- ### Compiled Function: `CL:NCONC`
- ```prolog
- f_nconc(RestNKeys, FnResult) :-
- GEnv=[bv(u_lst, Lst_In), bv(rest, Rest_In)],
- opt_var(ReplEnv, u_lst, Lst_In, true, [], 1, _55777686, RestNKeys),
- as_rest(rest, Rest_In, 1, RestNKeys),
- catch(( ( get_var(GEnv, rest, IFTEST),
- ( IFTEST\==[]
- -> get_var(GEnv, rest, Rest_Get14),
- f_nconc(Rest_Get14, Rest_conc_Init),
- LEnv=[bv(u_rest_conc, Rest_conc_Init)|GEnv],
- get_var(LEnv, u_lst, Lst_Get),
- ( is_consp(Lst_Get)
- -> get_var(LEnv, u_lst, Lst_Get22),
- f_last(Lst_Get22, [], Rplacd_Param),
- get_var(LEnv, u_rest_conc, Rest_conc_Get),
- f_rplacd(Rplacd_Param, Rest_conc_Get, Rplacd_Ret),
- get_var(LEnv, u_lst, Lst_Get24),
- LetResult=Lst_Get24
- ; get_var(LEnv, u_rest_conc, Rest_conc_Get25),
- LetResult=Rest_conc_Get25
- ),
- _55777936=LetResult
- ; get_var(GEnv, u_lst, Lst_Get28),
- _55777936=Lst_Get28
- )
- ),
- _55777936=FnResult
- ),
- block_exit(nconc, FnResult),
- true).
- :- set_opv(nconc, symbol_function, f_nconc),
- DefunResult=nconc.
- ## EXEC
- % 292 inferences, 0.000 CPU in 0.000 seconds (100% CPU, 957581 Lips)
- NCONC
- ```
- ```cl
- CL-USER> (defun mapcan (fn &rest lsts)
- CL-USER>>> (apply #'nconc (apply #'mapcar fn lsts)))
- ```
- ```prolog
- :- lisp_compiled_eval(
- [ defun,
- mapcan,
- [u_fn, c38_rest, u_lsts],
- [ apply,
- function(nconc),
- [apply, function(mapcar), u_fn, u_lsts]
- ]
- ]).
- ## COMPILER
- % 171,410 inferences, 0.042 CPU in 0.042 seconds (100% CPU, 4061609 Lips)
- lambda_def(defun, mapcan, f_mapcan, [u_fn, c38_rest, u_lsts], [[apply, function(nconc), [apply, function(mapcar), u_fn, u_lsts]]]).
- arglist_info(mapcan, f_mapcan, [u_fn, c38_rest, u_lsts], arginfo{all:[u_fn], allow_other_keys:0, aux:0, body:0, complex:[rest], env:0, key:0, names:[u_fn, u_lsts], opt:0, outer:ReplEnv, req:[u_fn], rest:[u_lsts], sublists:0, whole:0}).
- init_args(2, f_mapcan).
- ```
- ### Compiled Function: `CL:MAPCAN`
- ```prolog
- f_mapcan(Fn_In, RestNKeys, FnResult) :-
- GEnv=[bv(u_fn, Fn_In), bv(u_lsts, Lsts_In)],
- as_rest(u_lsts, Lsts_In, 0, RestNKeys),
- catch(( ( get_var(GEnv, u_fn, Fn_Get),
- get_var(GEnv, u_lsts, Lsts_Get),
- f_apply(f_mapcar, [Fn_Get, Lsts_Get], Nconc_Param),
- f_nconc(Nconc_Param, Nconc_Ret)
- ),
- Nconc_Ret=FnResult
- ),
- block_exit(mapcan, FnResult),
- true).
- :- set_opv(mapcan, symbol_function, f_mapcan),
- DefunResult=mapcan.
- ## EXEC
- % 292 inferences, 0.001 CPU in 0.001 seconds (100% CPU, 520194 Lips)
- MAPCAN
- ```
- ```cl
- CL-USER> (DEFUN permute (LIST)(IF LIST (MAPCAN #'(LAMBDA (x)(MAPCAR #'(LAMBDA (y)(CONS x y) )
- CL-USER>>> (permute (REMOVE x LIST) ) ) ) LIST) '(NIL) ) )
- ```
- ```prolog
- :- lisp_compiled_eval(
- [ defun,
- u_permute,
- [list],
- [ if,
- list,
- [ mapcan,
- function(
- [ lambda,
- [u_x],
- [ mapcar,
- function(
- [ lambda,
- [u_y],
- [cons, u_x, u_y]
- ]),
- [u_permute, [remove, u_x, list]]
- ]
- ]),
- list
- ],
- [quote, [[]]]
- ]
- ]).
- ## COMPILER
- % 392,998 inferences, 0.089 CPU in 0.094 seconds (95% CPU, 4417651 Lips)
- lambda_def(defun, u_permute, f_u_permute, [list], [[if, list, [mapcan, function([lambda, [u_x], [mapcar, function([lambda, [u_y], [cons, u_x, u_y]]), [u_permute, [remove, u_x, list]]]]), list], [quote, [[]]]]]).
- arglist_info(u_permute, f_u_permute, [list], arginfo{all:[list], allow_other_keys:0, aux:0, body:0, complex:0, env:0, key:0, names:[list], opt:0, outer:ReplEnv, req:[list], rest:0, sublists:0, whole:0}).
- init_args(x, f_u_permute).
- ```
- ### Compiled Function: `U::PERMUTE`
- ```prolog
- f_u_permute(List_In, FnResult) :-
- GEnv=[bv(list, List_In)],
- catch(( ( get_var(GEnv, list, IFTEST),
- ( IFTEST\==[]
- -> get_var(GEnv, list, List_Get27),
- f_mapcan(closure(kw_function,
- ClosureEnvironment25,
- WholeArgs11,
- LResult23,
- [u_x],
- ((append([X_In], RestNKeys10, WholeArgs11), ClosureEnvironment25=[[bv(u_x, X_In)]|GEnv], del_attr(RestNKeys10, freeze), true), get_var(ClosureEnvironment25, list, List_Get22), get_var(ClosureEnvironment25, u_x, X_Get21), f_remove(X_Get21, List_Get22, [], Permute_Param), f_u_permute(Permute_Param, Permute_Ret), f_mapcar(closure(kw_function, ClosureEnvironment, WholeArgs14, LResult, [u_y], ((append([Y_In], RestNKeys13, WholeArgs14), ClosureEnvironment=[[bv(u_y, Y_In)]|ClosureEnvironment25], del_attr(RestNKeys13, freeze), true), get_var(ClosureEnvironment, u_x, X_Get), get_var(ClosureEnvironment, u_y, Y_Get), LResult=[X_Get|Y_Get]), [lambda, [u_y], [cons, u_x, u_y]]), [Permute_Ret], LResult23)),
- [ lambda,
- [u_x],
- [ mapcar,
- function(
- [ lambda,
- [u_y],
- [cons, u_x, u_y]
- ]),
- [u_permute, [remove, u_x, list]]
- ]
- ]),
- List_Get27,
- [],
- TrueResult),
- _56964434=TrueResult
- ; _56964434=[[]]
- )
- ),
- _56964434=FnResult
- ),
- block_exit(u_permute, FnResult),
- true).
- :- set_opv(u_permute, symbol_function, f_u_permute),
- DefunResult=u_permute.
- ## EXEC
- % 293 inferences, 0.001 CPU in 0.001 seconds (100% CPU, 423616 Lips)
- PERMUTE
- ```
- ```cl
- CL-USER>
Add Comment
Please, Sign In to add comment