Skip to main content

All Questions

1 vote
2 answers
145 views

Scheme - function to count occurrences of atom in argument

I'm new to scheme and trying to learn functions. I want to create a function where I can count all occurrences of the atom "a" in an argument. This is what I have written so far. I'm not ...
Maryam's user avatar
  • 11
2 votes
1 answer
53 views

Understanding a construction (para . contents) and continuing education

I've just started the Scheme Lisp learning and needed some illumination. I've hit a snippet at a site https://www.gnu.org/software/guile/manual/html_node/Types-and-the-Web.html that I haven't caught (...
trzczy's user avatar
  • 1,501
2 votes
2 answers
1k views

Passing a function as an argument - lambda expression error?

I am trying to create a function that accepts a list and a function as parameters and applies that function to each element in the List. Here is my attempt: (defun filter(fn L) (if (eq 0 (length L))...
LuXxenatorX's user avatar
10 votes
1 answer
952 views

Clojure, can macros do something that couldn't be done with a function

I'm learning Clojure macros, and wonder why we can't use just functions for metaprogramming. As far as I know the difference between macro and function is that arguments of macro are not evaluated ...
Tuomas Toivonen's user avatar
1 vote
5 answers
972 views

Why some? returns true when it takes false as a parameter in Clojure?

I couldn't understand the intent of some? function in Clojure. I need some function(built-in) that returns false when it takes (nil or false). Here is the example: (some? "1") => true (some? ...
Ertuğrul Çetin's user avatar
2 votes
3 answers
268 views

What are those functional functions called?

I'm looking for a functional way to implement this: list = [a b c d e f] foo(list, 3) = [[a d] [b e] [c f]] A potential solution is: foo(list,spacing) = zip(goo(list,spacing)) Where, for example, ...
MaiaVictor's user avatar
  • 53.1k
0 votes
2 answers
2k views

Evaluate function from list in lisp

I need to write a function in lisp with two arguments - list of argumentless functions and list of integers. I need to evaluate functions from first list in order given by a second, i.e. (fun '(#'a #'...
Pax0r's user avatar
  • 2,473
3 votes
4 answers
7k views

Scheme - have a function return a function

I want to use this code in the following way: if I enter: ((function1 5) 2) where function1 executes its procedure based off the 5, and returns a function2 that executes something based on the 2. Is ...
Jeeter's user avatar
  • 6,105
3 votes
2 answers
190 views

Why can't I use the function symbol(#') extracted from the list in Common lisp?

The first one doesn't work. But the second one works,which make me confused.. Could anyone explain a bit about that? CL-USER> (funcall (first '(#'+ +)) 1) ; Evaluation aborted on #<TYPE-ERROR ...
Hanfei Sun's user avatar
  • 47.2k
7 votes
1 answer
3k views

Too many arguments for function

I'm starting to learn Lisp with a Java background. In SICP's exercise there are many tasks where students should create abstract functions with many parameters, like (define (filtered-accumulate ...
Stan Kurilin's user avatar
  • 15.8k
1 vote
1 answer
418 views

What is wrong with this Lisp Function?

This function is a CLisp function, this is part of a homework problem, but which is supposed to be written in this different format (the second function). (defun range (m M) (cond ((> m M) '() ) ((...
xboarder's user avatar
1 vote
2 answers
206 views

scheme2lisp::define function and pass it as parameter

I need to translate some code from Scheme to Common Lisp. Now, I have something like this: (defun sum (term a next b) (if (> a b) 0 (+ (term a) (sum term (next a) b)))) (defun sum-int (...
Stan Kurilin's user avatar
  • 15.8k
15 votes
7 answers
1k views

can if be a proper function rather than a special form

I finally started learning functional languages (emacs lisp) and it makes explicit distinction between functions and special forms such as flow control , for example if. Is there a fundamental/...
Anycorn's user avatar
  • 51.6k