lisp

What is fexpr in php?

你离开我真会死。 提交于 2019-12-25 17:07:40
问题 What is fexpr in PHP? As I caught so far, It is a kinda function in Lisp language: In Lisp programming languages, a fexpr is a function whose operands are passed to it without being evaluated. I was reading an article which had deeply discussed PHP constructs, I faced fexpr there & Googling led me into the fact that it is fundamentally a Lisp concept! That's why I can't clearly wrap my head around. Would you mind explain what fexpr is in PHP? and (if its semantically conceivable) Please

What is fexpr in php?

和自甴很熟 提交于 2019-12-25 17:07:12
问题 What is fexpr in PHP? As I caught so far, It is a kinda function in Lisp language: In Lisp programming languages, a fexpr is a function whose operands are passed to it without being evaluated. I was reading an article which had deeply discussed PHP constructs, I faced fexpr there & Googling led me into the fact that it is fundamentally a Lisp concept! That's why I can't clearly wrap my head around. Would you mind explain what fexpr is in PHP? and (if its semantically conceivable) Please

Insert Node into a Tree - Racket

与世无争的帅哥 提交于 2019-12-25 16:46:49
问题 I am trying to add a new node to the tree. The following are my definitions and function type: (define-struct (Some T) ([value : T])) (define-type (Option T) (U 'None (Some T))) (define-type BST (U 'E Nd)) (define-struct Nd ([root : Integer] [lsub : BST] [rsub : BST])) (: insert : Integer BST -> BST) ;; insert an item into a tree ;; note: do not insert duplicate items (define (insert n x) (match x ('E 'E) ((Nd ro ls rs) (cond ((= (size x) 1) (Nd ro (Nd n 'E 'E) 'E)) (else (Nd ro ls rs))))))

flatten list in lisp

被刻印的时光 ゝ 提交于 2019-12-25 16:22:31
问题 So I've been looking at flattening a list in lisp. However, what I wanted to do is flatten a list level by level. So instead of having (flatten '(a (b (d (g f))) e)) = (a b d g f e) i want (flatten '(a (b (d (g f))) e)) = (a b (d (g f )) e ) Any idea on how to do this guys? Much appreciated =) 回答1: You could do something like this, for example: (defun fletten-level (tree) (loop for e in tree nconc (if (consp e) (copy-list e) (list e)))) (fletten-level '(a (b (d (g f))) e)) ;; (A B (D (G F)) E

Add times in buffer

社会主义新天地 提交于 2019-12-25 13:47:26
问题 Suppose I have an emacs buffer which contains times in the format minutes'seconds'' and in the format minutes' as well as seconds'' for example 5'30'', 6'15'', 10' and 1''. Is it possible to add all times in the buffer automatically with output (in the minibuffer) in the format minutes'seconds'' (here = 21'46'')? 回答1: Is this what you want? (defun add-times () (interactive) (let ((minutes 0) (seconds 0)) (save-excursion (goto-char (point-min)) (while (re-search-forward "\\([0-9]+\\)'\\('\\)?"

Return elements if they are in two given lists in lisp

无人久伴 提交于 2019-12-25 09:40:32
问题 How can i return elements if they are in two given lists? Example: L1 = (a b c d e a b c) L2 = (a d f g k c c) Result = (a a a c c c c d d) I want to remove elements that arent in both lists and, then, append the resultant lists 回答1: You can start with a hash table, mapping a list element to a pair, first being elements from the first list, second - elements from the second. Then you collect the elements: (defun common-elements (l1 l2 &key (test 'eql)) (let ((ht (make-hash-table :test test))

LISP function affecting other function [duplicate]

≡放荡痞女 提交于 2019-12-25 08:23:11
问题 This question already has answers here : Why does an elisp local variable keep its value in this case? (3 answers) Closed 3 years ago . I noticed that when I call the function fillBoard, it seems to work as it fills the list passed to it as I want, but it has a very weird side effect. Somehow once fillBoard is called, the clearBoard function will only return the list returned by fillBoard. Additionally if I call fillBoard again it will continue to update the value returned in clearBoard. As

Scheme error “except: misuse of unit import keyword”

拜拜、爱过 提交于 2019-12-25 06:51:09
问题 I'm writing a function that returns elements which appear in one list and not in another. For example, (except '(a b c) '(a d b e f)) will return '(c) . The first argument can be an atom, and both are assumed to be flat. Here's my code: (define (except lm ln) (cond ((null? ln) lm) ((not (list? lm)) (cond ((in? lm ln) '()) (#t lm))) ((null? lm) '()) ((in? (car lm) ln) (except (cdr lm) ln)) (#t (cons (car lm) (except (cdr lm) ln))))) Then an error returns saying "except: misuse of unit import

how to write alike display (printf) to file in scheme?

别说谁变了你拦得住时间么 提交于 2019-12-25 06:07:07
问题 Using TinyScheme. I'm writing my code to file (solved it in 50% here: How to write to a file in tinyscheme?) with: (with-output-to-file "biophilia.c" (lambda () (write code) )) ; and segmentation fault comes here but it writes my code with "" qotes and \n\r as is so it doesn't translate it to newline. I need to write code like it looks with (display code) in example in racket docs there is printf but seems like TinyScheme implementation got no printf, maybe I need to discover (add code of it)

Why am I getting this lambda expression error, and what can I do about it?

流过昼夜 提交于 2019-12-25 04:56:19
问题 I'm pretty new to lisp; I was wondering if anyone here could help me out. I have the following code snippet: (defun write-lookup (binding-list pattern fact) (cond ; No bindings have been stored ; Return the binding list with a new one! ((not binding-list) (cons (cons pattern fact) nil)) ; A list of bindings is being stored (cond ; The current binding matches ((equal (caar binding-list) pattern) ; Return the binding-list if value matches, nil else (if (compare pattern fact) binding-list nil))