Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6801143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:03:48+00:00 2026-05-26T19:03:48+00:00

I am trying to write a Lisp function that can take optional and keyword

  • 0

I am trying to write a Lisp function that can take optional and keyword arguments. The function begins

(defun max-min (v &optional max min &keyword (start 0) (end nil))

When I try to call the function using the keyword arguments but not the optional ones, I get an error. What I’m trying to do is

(max-min #(1 2 3 4) :start 1 :end 2)

I’m getting the error Error: :START' is not of the expected type REAL'

I assume that this is because it is trying to bind :start to max. How can I get this to work? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:03:49+00:00Added an answer on May 26, 2026 at 7:03 pm

    You need to call that function with the required parameter, the optional parameters and then the keyword parameters. How should it work otherwise? Your call lacks the optional parameters. If you want to specify keyword parameters in the call, the optional are no longer optional.

    (max-min #(1 2 3 4) 0 100 :start 1 :end 2)
    

    The basic style rule:

    Don’t mix optional with keyword parameters in a function. Common Lisp for example uses it in some place and it is a source of bugs.

    CL:READ-FROM-STRING is such an example.

    read-from-string string
                     &optional eof-error-p eof-value
                     &key start end preserve-whitespace
    

    http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_fro.htm

    This works:

    (read-from-string " 1 3 5" t nil :start 2)
    

    This may work also:

    (read-from-string " 1 3 5" :start 2)
    

    But the user forgot to specify the EOF-ERROR-P and EOF-VALUE. The Lisp compiler may not complain and the user will wonder why it won’t start at 2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I trying to complete this exercise; Write a Lisp function that takes as input
I'm trying to write a little Emacs Lisp script that reads a csv file
I'm trying to write a regex function that will identify and replace a single
I'm trying to write a function in Common Lisp similar to the built in
I'm trying to write a macro in Lisp that re-implements let using itself. This
I'm trying write a code that can the set property value through the lambda
im trying to write a script , that can rewrites urls in slug way
Trying to write a PowerShell cmdlet that will mute the sound at start, unless
Trying to write a couple of functions that will encrypt or decrypt a file
im trying to write an app that will display a list off lines from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.