FAQ Database Discussion Community


Wrong number of arguments while reversing a number in scheme

scheme,lisp
I am trying to write a program in Scheme that reverses a given number. However, the problem is that although I have got my recursion right, Scheme is saying that the number of arguments to my recursive call is not correct. What is wrong in this code? Why do I...

Extracting nodes form dotted list (edges) in CLISP

graph,lisp,edge,land-of-lisp
I'm a "Nil" or () in Lisp World. I wanted to get a list of all nodes in edge list and I wrote a code to solve this problem. But I met some unexpected problem. (Codes from 'Land of Lisp' - chapter 8) ;; Creating edge list (defun random-node ()...

Common Lisp: How to quote parenthese in SBCL

lisp,common-lisp,sbcl,quote
In Common Lisp, the special operator quote makes whatever followed by un-evaluated, like (quote a) -> a (quote {}) -> {} But why the form (quote ()) gives me nil? I'm using SBCL 1.2.6 and this is what I got in REPL: CL-USER> (quote ()) NIL More about this problem:...

If strings are vectors, why are they immutable?

lisp,common-lisp
if strings are vectors of characters, and a vector's elements can be accessed using elt, and elt is setf-able - then why are strings immutable?

Create an array of single-float from double-float in lisp?

lisp,common-lisp,sbcl
When I try to create a single-float array like this, i get: (make-array 2 :element-type 'single-float :initial-contents #(3.0 4.0)) , i get the following error: The value 3.0 is not of type SINGLE-FLOAT Is there a way to create a single-float array from a simple vector of double-float?...

Scheme-Wrong type to apply #f error in code for checking a prime number

scheme,lisp
I am writing a program to check if a number is prime in Scheme. However, I have written the following code. I check out another question on StackOverflow where the OP was getting the same error. I checked whether I was committing the same mistake. I was not. I have...

Can't get the post in LISP hunchentoot

post,lisp,common-lisp,hunchentoot
I try to implement a simple post example based on Hunchentoot. Here is the code: (define-easy-handler (test :uri "/test") () (with-html-output-to-string (*standard-output* nil :prologue t :indent t) (:html (:body (:h1 "Test") (:form :action "/test2" :method "post" :id "addform" (:input :type "text" :name "name" :class "txt") (:input :type "submit" :class "btn"...

Emacs + SLIME + SBCL (Windows)

windows,emacs,lisp,sbcl,slime
I'm attempting to get Emacs, Slime and SBCL to work together on a Windows 7 machine. I use Linux typically, so I'm not experienced with the process. The problem is that I get this error when I attempt to start SLIME: Searching for program: permission denied, sbcl Here's my Emacs...

Difference between CDR, CAR and REST, FIRST and possible implementation?

list,lisp,common-lisp,cons,cdr
I'm learning a little bit about functional programming in LISP and here's what I've bumped into: LISP uses CAR, CDR functions as well as FIRST and REST functions. Both related to lists. From what I've learned so far, there's a difference between these two, but I don't quite see what...

Returning from a function inside when statement

scheme,lisp,racket
All I'm trying to do is use a when statement to return a value :( I want the functionality of: if(x) return y And I'm trying to use: (when (x) y) But the when statement is not evaluating in a way that exits the function and return y. It just...

Printing ith row jth column value in lisp

arrays,multidimensional-array,lisp,clisp
I am taking input N as number of rows of a 2D matrix in lisp, where each row can have maximum of 5 elements in it. So i make it like this. Now for eachrow as it can have any number of elements between 0 to 5. So I made...

Append list from assoc to another list in Scheme

scheme,lisp,r5rs
I'm a bit confused on how to append a list that I've gotten from the assoc procedure into another list, here is what I have: (define new-list (list 'test)) (define source-a (list '(a foo) '(b bar) '(c hello))) (append new-list (assoc 'a source-a)) (display new-list) The output is just (test)...

Why does a macro that uses “let” expand differently from one that doesn't?

macros,lisp,common-lisp,let
I am new to Lisp and I am reading through Doug Hoyte's Let Over Lambda and he presents Paul Graham's nif macro in Chapter 3. I was playing around with that and made these two macros: (defmacro niffy (expr pos zero neg) `(cond ((plusp ,expr) ,pos) ((zerop ,expr) ,zero) (t...

Appending to the result of a “loop-collect” in Lisp

loops,lisp,common-lisp
Let's say I run the following (loop for i to 4 collect i) Then I get a list (0 1 2 3 4). Now, if I want to append something to the result, I may use rplacd on its last element, but since Lisp lists are linked lists, it's not...

Char Comparison in Common Lisp

sorting,char,comparison,lisp,common-lisp
How can i compare characters with Common Lisp? I have google it and found out that there are some functions to do the comparison, like char=, char/=, char<, char>, char<=, and char>=. But, i can't use all of the functions just like: (char= 'a 'a) (char< 'a 'b) If i...

Lisp: Why does (- 1e16 1) yield 10000000000000000 not 9999999999999999?

floating-point,scheme,lisp
Or rather, why does (= 1e16 (- 1e16 1)) return true? How can I receive more accurate answer?

LISP function to return the greater number

function,parameters,lisp,common-lisp
I feel like an idiot asking for help for this, but I have been stuck for hours now, and I haven't been able to find anything on the internet that can help me. I am trying to write a function in LISP that takes in two parameters and returns the...

How to use a parameter in a macro call?

macros,lisp,common-lisp,sbcl
I have defined the following simple macro: (defmacro define-class (class-name) `(defclass ,class-name ()())) And now I want to use it in the following function: (defun create-data (mode) (define-class mode)) After compiling the last function I get the following message, the variable MODE is defined but never used. And when I...

Common Lisp Object System method execution order

lisp,common-lisp,clos
I have the following two classes: (defclass person () ()) (defmethod speak ((s person) string) (format t "-A" string)) (defmethod speak :before ((s person) string) (print "Hello! ")) (defmethod speak :after ((s person) string) (print "Have a nice day!")) (defclass speaker (person) ()) (defmethod speak ((i speaker) string) (print "Bonjour!"))...

Parsing XML with emacs elisp and finding a nested attribute

xml,parsing,emacs,lisp,elisp
Since two days I am working on the following problem: I have some xml wich looks like this: <grammar> <l> <f form="paradāra"><s stem=""/><m meaning="anothers wife; adultery"/></f> <f form="abhimarśeṣu"><s stem="" meaning=""/><m meaning=""/></f> <f form="pravṛttān"><s stem="" meaning=""/><m meaning=""/></f> <f form="mahipatis"><s stem="" meaning=""/><m meaning=""/></f> </l> <l> <f form="udvejana"><s...

Can CONS objects be used as a key to a hash table?

lisp,common-lisp,gnu-common-lisp
I've been playing with LISP lately, and I want to attempted to optimize a terribly inefficient recursive function by caching it's output so it only runs each combination of parameters once. I want to save the results into hash table, using either (LIST a b) or (CONS a b) as...

Lisp - append to a list

lisp,common-lisp
I am new to lisp. I didn't properly understand how to implement append function on a list. I tried the following program. (defvar temp) (setq temp '()) (append temp (logxor 1 0)) temp seems to store only NIL value when it should be storing 1 in it. ...

CAR and CDR in LISP

lisp,clisp,cdr
Suppose there's a LISP list L described by ((A B) (C)) How to print the result of (CAR L) and (CDR L)? (in clisp interpreter) I am able to print these simple statements like (CAR `(A B C)) which gives A. But how do I define the list and CAR...

Finding deepest node in a tree (Lisp)

tree,lisp,common-lisp,tree-traversal,postorder
I am wanting to go through a tree in lisp and find the deepest (or furthest from the root node) by using a tree in the form of a list. So far my idea has been to keep on cutting the tree into left and right sub trees (assuming that...

How do to count the number of elements in a list?

lisp
So here is my code. It should count the number of elements in a list but instead it prints a zero even though a list contains something. (defun my-list (listA) (setq count 0) (loop for i in listA if(null i) count else do (setq count(+ count 1)))) ...

Difference between (loop for) and (loop :for) in Common Lisp [duplicate]

lisp,common-lisp
This question already has an answer here: Why do some people use keywords for the clauses in the loop macro? 3 answers I just saw the answer of Sylwester to this question, and I thought strange that the loop has colons everywhere. Usually, I would write (loop for n...

Common-LISP debugging (code included)

debugging,lisp,common-lisp
I hope to get a quick fix to my code, which takes in a list of numbers, numberlist, and a threshold and return the number of items in numberlist that are greater than threshold. I just can't figure out what's wrong, and I am not familiar with debugging. I am...

Why does lisp use gensym and other languages don't?

lisp,common-lisp
Correct me if I'm wrong, but there is nothing like gensym in Java, C, C++, Python, Javascript, or any of the other languages I've used, and I've never seemed to need it. Why is it necessary in Lisp and not in other langauges? For clarification, I'm learning Common Lisp.

Understanding “let” expression in LISP

lisp,common-lisp,let
I am extremely new to lisp, had previous experience with functional programming (Haskell, SML). Why is this code returning 14, and not 10 (ie. 1 + 2y + 3 + 1)? (defvar x 1) (defun g (z) (+ x z)) (defun f (y) (+ (g 1) (let ((x (+ y...

LISP Function that Returns True If Atom Is In List

list,recursion,lisp,common-lisp
I'm trying to write a function (deep-find) that takes in a list and another argument and returns T if that argument is present in the list. For example, if I called (deep-find '(A B (C D)) 'C) it should return true, but if I called (deep-find '(A B (C D))...

Convert lisp function to use map

lisp,common-lisp
Hello I am looking forward to convert my existing function: (defun checkMember (L A) (cond ((NULL L) nil) ( (and (atom (car L)) (equal (car L) A)) T ) (T (checkMember (cdr L) A)))) To use map functions, but i honestly cant understand exactly how map functions work, could you...

How to use FFI:def-call-in in clisp

lisp,common-lisp,ffi,clisp
I have figured out how to make use of shared objects created from C code into Clisp using FFI:def-call-out but I am not able to figure out how to use FFI:Def-call-in. I don't know the process and actually I am confused if clisp will also create some .so file that...

Mapping function in LISP

recursion,mapping,lisp
I need your help on something. I have a list in input: (1 ((2 3) (4 ((5) (6)))) ((7 8) (9 10)) 11) I want to receive in output the following: ((1 2 3 7 8 11) (1 2 3 9 10 11) (1 4 5 7 8 11) (1...

How to call a macro with a parameter instead of list in LISP?

lisp,common-lisp
Based on the example provide in the practical common lisp reference, I define a macro to create a class as followed. (defmacro define-class (class-name class-slot) `(defclass ,class-name () ,(mapcar #'slot->defclass-slot class-slot)))) The function slot->declass-slot take a single argument and generate a standard line describing a slot in a class. The...

Summing all the multiples of three recursively in Clojure

recursion,clojure,lisp
Hi I am a bit new to Clojure/Lisp programming but I have used recursion before in C like languages, I have written the following code to sum all numbers that can be divided by three between 1 to 100. (defn is_div_by_3[number] (if( = 0 (mod number 3)) true false) )...

Exceed evaluation depth when forward function in Emacs Lisp

emacs,lisp,elisp
Here is just a simplified code snipped I have not managed to work. I do not understand what is wrong. (defun enumerate-indicies (func) (let ((index 0)) (while (< index 5) (funcall func index) (setq index (1+ index))))) (defun enumerate-multiplied-indicies (func) (enumerate-indicies #'(lambda (index) (funcall func (* 10 index))))) The following...

Modify list and return it inside a function in lisp

lisp,elisp,common-lisp
(defun testthis (node index newvalue) (set-nth node index newvalue) node ) I would like to modify the nth element of a list in a function and then returns this list to save the modification performed. How can I do a such function in lisp?...

Simulate scheme define in common lisp

scheme,lisp,common-lisp
I wonder how to simulate the scheme define in common lisp,and want to write a macro for simulate the define. So what's the different between cl's defun deparameter defvar and scheme's define ,and how i can do this?

What does the ALSO keyword mean in MLISP?

lisp
I've been looking over the source code for the early AI project Parry recently. It's tricky because the bulk of the code is written in MLISP, for which no working implementation still exists (that I know of). Instead, I've been using the language specification (MLISP Users' Manual and the earlier...

Value from binding in LFE interpreter using Erlang

erlang,lisp,lfe
I'd like to use Lisp Flavored Erlang as a scripting extension language for an Erlang application. If you want, in a similar way GNU Emacs is configured and extended via Emacs Lisp. I know that the argument is wide and structured; but in the specific case of this question I'd...

setf seems to change both its arguments when they are given by aref

lisp
In Lisp, I've defined an array a and then let b be equal to a. I now want to redefine an entry of b to be equal to a different entry in a, like this: (setf a (make-array '(2 2) :initial-contents '((1 2) (3 4)))) (setf b a) (setf (aref...

CLISP recursive powers of cubes function that returns a list

function,recursion,lisp,common-lisp,exponents
I'm looking for help in writing a function that returns a list of the first 15 cubes. Here's what I have so far, and I'm getting a stack overflow: (defun cubes (dec lst) ;takes a number and a list as params (if (= dec 0) lst ;if dec is 0...

how to change the value of sp-navigate-reindent-after-up in smartparens

emacs,lisp,elisp,parentheses
I want to change the default behavior of smartparens to remove the whitespace before the close delimiter. I mean, when I type ) after (a b c |, I hope the final result is (a b c)|. Here, the | is cursor. I searched the documentation of smartparens, and find...

Get element from list of list in lisp

lisp,elisp,common-lisp
I am a beginner with lisp. I manipulate list of list: ((name1, second) (name2, second2)) The goal of my function is to get the second element of the list that have name as it first node. For example: my list is: ((name1, second1) (name2, second2)) getelement list name1 should return...

Structuring large Lisp applications

lisp,common-lisp,quicklisp,asdf
I am currently trying to wrap my head around packages, systems & co. I now have read Packages, systems, modules, libraries - WTF? a few times, and I think I'm still having difficulties to get it right. If I simply want to split a Lisp source file into two files,...

LISP macro fail, crashes slime

lambda,macros,lisp,common-lisp,slime
I am using common lisp with slime in emacs and am trying to define a simple macro. However when I run the macro, the emacs slime buffer becomes unresponsive and my computer quickly becomes unusable. Even after exiting emacs I get error messages at the bash prompt about not being...

What's the R equivalent of progn in lisp?

r,lisp
In lisp there is syntax to execute several expressions in sequence within function arguments. Given R's lispy origins, I'm wondering is there an equivalent feature in R? I'm imagining writing something like the following: with(heat, do(qqnorm(loss), qqline(loss))) ...

How to create a list of sublists in Lisp without map?

list,recursion,lisp,sublist
I'm trying to make a function that creates a list of all sublists in the given list. What I mean is, when I've got a list: (4 (a g b) g (1 2 3) g (4 5 6)) I want a list: ((a g b) (1 2 3) (4 5...

Insertion into a list doesn't reflect outside function whereas deletion does?

list,lisp,common-lisp
I am new to Lisp. Deletion of an item in a list by a function gets reflected outside the function but insertion doesn't. How can I do the same for insertion? For example (defun test (a b) (delete 1 a) (delete 5 b) (append '(5) b) (member '5 b)) (setq...

No-argument (and) returns t

clojure,scheme,lisp,common-lisp
Both CL and Scheme define (and) to return t (or #t) with no arguments. I'm trying to understand the rationale for this. My naive assumption is that an empty set is false, and passing in zero arguments feels like passing in nothing that can be true. Edit: clojure follows the...

Parsing a comma separated string in lisp

lisp,common-lisp
I am trying to parse a comma separated string with Common lisp with the function below. For (separate-on-comma "a,b,c") I would expect the output ("a" "b" "c") but instead I get ("c" "c" "c"). What do I miss here? (defun separate-on-comma (line) (loop with fields = () with field =...

How to use do in lisp?

function,lisp,common-lisp
What I'm trying to do is to write a function that which will restart a game of tic-tac-toe after it ends. What is supposed to happen is that the player will be asked if they want to play another game. If they do, then they click yes and a function...

Invalid specialized parameter in method lambda list

lisp,common-lisp
I am trying to write a simple coin flip program in Common Lisp. This is the code I have (defun yn (let ht (random 1) (if (eq ht 1) (princ heads) (princ tails)) ) ) It seems simple enough, but I keep getting the error: "Invalid specialized parameter in method...

Need help getting CLisp to read standard input into a list

python,lisp,common-lisp,clisp
I'm working on converting some existing Python code to CLisp just as an exercise ... The program reads a list of numbers and creates mean, min, max and standard deviation from the list. I have the file-based function working: (defun get-file (filename) (with-open-file (stream filename) (loop for line = (read-line...

What's the difference between (list nil) and '(nil) in Lisp? [duplicate]

lisp,common-lisp,literals
This question already has an answer here: Why does this function return a different value every time? 4 answers Unexpected persistence of data [duplicate] 1 answer First of all, let me say I'm a beginner in Lisp. To be honest I have been a beginner for some time now,...

Documentation for CL's loop macro

loops,documentation,lisp,common-lisp
I'm looking for official documentation for the common lisp loop macro, but all I can find are tutorials and examples. Where can I find this documentation?

How to express BNF using Lisp?

lisp,racket,grammar,bnf
I want to express a grammar rule that is written in BNF using Lisp. here is the rule. It is important to note that non-terminals are represented in capital letters and the terminals are represented in small letters: A -> a A b I tried to use the define function...

Reverse list in Racket in O(n)

scheme,lisp,racket
I need to write a recursive function in Scheme which takes a list of atoms and reverses it in linear time. I am only allowed to use define, lambda, cons, car, cdr, cond, let, and null? . Here is what I have so far: (define reverse (lambda (lat) (cond ((null?...

How to move a file in Lisp using rename-file

lisp,common-lisp,pathname
What's the best way to move a file in Lisp in an implementation-independent way? For example I have an image file: (setq oldpath #P"SERVER:PICTURES;TEMP;PHOTO.PNG") and I want to move it out of the TEMP directory into the PICTURES directory. This seems to work: (setq newpath (make-pathname :host (pathname-host oldpath) :directory...

Racket: using big bang and on-click

scheme,lisp,racket
I've somehow been able to draw a small basic image in racket (a house). Now, what I'm stuck with is, using big-bang to draw the image -- and then being able to click the roof of the house and have it change to another color. This is what I have...

Parenscript and implicit Return

javascript,lisp,common-lisp,parenscript
Is there anyway to turn off Parenscript's implicit Return? I'm trying to write the following code: function () = { dialog.show();}; But Parenscript inserts an implicit return: (ps (lambda () (chain dialog (show)))) => function () = { return dialog.show();}; ...

Run an ABCL code that uses cl-cppre

java,lisp,common-lisp,abcl,cl-ppcre
With reference to my previous question, Executing a lisp function from Java I was able to call lisp code from Java using ABCL. But the problem is, the already existing lisp code uses CL-PPCRE package. I can not compile the code as it says 'CL-PPCRE not found'. I have tried...

How to return the value and name of a variable in Common Lisp

lisp,common-lisp
I'm trying to write a macro to return a variable's name and value in common lisp. How do I return the name and value of a variable in a LISP macro? So something like (RETURNVAL (x)) would return x has value 5...

lisp remove a the content of one list from another list

lisp,common-lisp
I have a list of string like this called F: ("hello word i'am walid" "goodbye madame") => this list contain two elements of string and I have another list call S like this ("word" "madame") => this contain two words now I want to remove the elements of the list...

Check list for strings using string?

string,lisp,racket
Hi I am having a little trouble testing a list to see if the list contains only strings. I am reading the documentation 2.3(Iterations, and Recursion) + 3.12 (Conditionals) and I can't quite seem to work lists in the way that I want. I'm trying to keep it as simple...

Are Lisp lists always implemented as linked lists under the hood?

linked-list,lisp,cpu-cache
Are Lisp lists always implemented as linked lists under the hood? Is this a problem as far as processor caching goes? If so, are there solutions that use more contiguous structures which help caching?...

Common Lisp - Giving &rest Lists as Arguments

arguments,lisp,common-lisp,sbcl
As a result of musings around an exercism problem, I am trying to write a function that takes an input number and an arbitrary length list of divisors to test, along with the expected divisibility (i.e. remainder 0) as a boolean, returning true if all expectations are met (defaulting to...

Read-line from socket-stream in lisp

sockets,tcp,lisp,common-lisp,usocket
I am working on a TCP client in lisp, and am having difficulties reading/printing the socket-stream correctly. When the client sends data to the server it should receive a response, and I need to write this to stdout. This works correctly, except I am having an issue where the response...

Scheme returning wrong type to apply for list input

scheme,lisp
I am trying to write a program which will add numbers in a list. However, when I give the input as a list, Scheme does not give me an output. My code is the following: (define (sumlist lst) (cond ( (pair? lst) (+ (car lst) (sumlist(cdr lst))) ))) Why does...

Defmacro that expands to defsetf

macros,lisp,common-lisp,backticks
I'm having some trouble with some nested backquotes in CL. I'm trying to create a macro define-access that takes two parameters, F and A. define-access should define a function and setf expansion for symbol F that acts just like the respective function and setf for A. The current code is...

Backquote String Interpolation

macros,lisp,common-lisp
Is it possible to use lisp's macro to do string interpolation? For instance, can I make a macro like this: (defmacro test (a) `",a") So that (test abc) returns "abc" as a string? I could probably cheat by quoting it and turning that quote into a string, but that doesn't...

in clojure, function argument type mismatch

clojure,functional-programming,lisp
clojure, function argument is vector, but it takes a map without problem. (defn flower-colors [colors] (str "The flowers are " (:flower1 colors) " and " (:flower2 colors))) (flower-colors {:flower1 "red" :flower2 "blue"}) ;; -> "The flowers are red and blue" Function flower-colors suppose to take vector type argument, but with...

How would I get the min/max of a list using a key

lisp,common-lisp
I currently have a list of objects, each containing a certain attribute. I would like to get the element of the list with the min attribute value. Is there a concise way of doing this? The python equivalent would be something like: min(d, key=d.get) Is there a way of getting...

Scheme full-house poke function

list,scheme,lisp,racket
I'm trying to define a function in Scheme that determines if a five-element list contains a full-house (that is, 3 elements are the same and the other 2 are the same, respectively). I have the outline in my head, although I'm messing up the syntax. I'm using and, let, to...

Not numeric atoms LISP

lisp,common-lisp
I want to ask why this function doesn't work... (defun nenum(ls) (cond ((null ls) nil) ((listp car(ls)) (nenum (rest ls))) ((numberp car(ls)) (nenum (rest ls))) (t (cons (car ls) (nenum (rest ls)))))) Example: (nenum '(l 1 i (b) (5) s -2 p)) --> (l i s p) Thank you!...

Return items of a list in Lisp

lisp
I have to write a program in Lisp that returns the first item of a list if it contains an even number of elements, and the last if it contains an odd number of elements. I need a little advice on where to start? I don't need whole program.

How to get a text to be executed in LISP?

lisp,common-lisp
Suppose that the following macro execution: (make-model '((1 2)(3 4)(5 6)(7 8))) , can generate the following list: ((MAKE-INSTANCE 'MODEL :NAME 7 :ID 8) (MAKE-INSTANCE 'MODEL :NAME 5 :ID 6) (MAKE-INSTANCE 'MODEL :NAME 3 :ID 4) (MAKE-INSTANCE 'MODEL :NAME 1 :ID 2)) If I store the result in a parameter...

Evaluating Function in Lisp

scheme,lisp
I'm new to Lisp and need help understanding this function and the evaluation of (map length '((a b c) (1 2 3 4 5) (v1 v2 v3 v4 v5 v6)))) The value is (3 5 6) (define (map f list) ; applies function f to each element of list (if...

combination of pair subsets from a list in lisp

list,lisp,subset
How to create all possible pairs subsets from a list in conman lisp. For example the list A contain four elements list A= ("A" "B" "C" "D") the expected output is as follows: (("A","B"),("A","C"), ("A","D"),("B","C"),("B","D"), ("C","D")) Could someone please help me out to generate these subsets. Thanks a lot...

SBCL Run Shell Command

python,shell,lisp,common-lisp,sbcl
I've seen Executing a shell command from Common Lisp and its answers, but I'm still not sure whether SBCL provides a way execute shell commands from code. The SBCL Manual does support POSIX, but I was hoping for something a bit more higher level. Specifically, I want to call a...

Lisp Function that Returns a Sum

list,sum,lisp,iteration,clisp
I am trying to write a weird function, so bear with me here. This function should take a list L as a parameter and have a sum variable. If L is not a list, it should return nil. Otherwise, it should iterate through each element of the list and do...

LISP: read number from user and commpare with array index

functional-programming,lisp,common-lisp
Hello guys I'm new In functional programming Really it is not Clear for me anyone can help me ? My Question just for getting the philosophy of writing on Functional programming language for example how I can write a program in Lisp language for reading the user inputs and compare...

EVAL/APPLY: too many arguments given to F

lisp,common-lisp,clisp
Hello why do i get *** - EVAL/APPLY: too many arguments given to F on function call with nested lists parameter. I cannot figure it out, since I passed a simple nested list. (defun f (L) (cond ((NULL l) nil) ((listp (car L)) (append (F(car L))) (F(cdr L) (car (F...

Common Lisp - Writing a function that detects circular lists

list,function,recursion,lisp,common-lisp
I have an assignment for my CS functional languages class where we must write a function able to detect whether or not a given list is circular at its beginning. The function has to be recursive. Let's name it circular : * (setf list1 '(a b c d)) * (rplacd...

Does anyone know if it is possible to return nothing in console for elisp after a function ends?

emacs,lisp,elisp,return-value
Right now whenever I try to not return anything, I get nil or t. The last spot of my function ends in an if statement that has nothing in the body. So like this: (if (counter<ten) () (...)) ...

Basic idea of Lisp Macro

macros,lisp,common-lisp
I try to do a very simple thing in Lisp - to find a way to turn on a global valuable nodebug t and then some of debug format form would be silence. To do that, I found I cannot grasp the difference of the following: (defparameter *nodebug* t) (setf...

LISP: Why doesn't mapcan accept my list give as parameters?

list,parameters,lisp,common-lisp,clisp
To simplify my question: why this works (mapcan #'(lambda (l) (list '1 '2) ) '(a b)) and this doesn't (mapcan #'(lambda (l) '(1 2) ) '(a b)) ? I have to write a function that substitutes an element through all elements of list D at all levels of a given...

How can I modify function bindings in Common Lisp?

variables,binding,scheme,lisp,common-lisp
Here is something you can do in Scheme: > (define (sum lst acc) (if (null? lst) acc (sum (cdr lst) (+ acc (car lst))))) > (define sum-original sum) > (define (sum-debug lst acc) (print lst) (print acc) (sum-original lst acc)) > (sum '(1 2 3) 0) 6 > (set! sum...

What does backtick mean in LISP?

lisp,common-lisp,backticks
I have this macro, which rewrites define. If I remove the " ` " backtick it won't work. What is the explanation? (defmacro define ((name &rest r) body) `(defun ,name ,r ,body)) ...

LISP Easy questio about creating new lists

lisp,common-lisp
A function that receives a list with sublist's M*N and returns the sum of all elements of the sublist's example: (solution '( (1 2 3) (4 5 6) ) ) return: (5 7 9) Sry for the bad english thks =)...