Jump to content
View in the app

A better way to browse. Learn more.

Opusmodus

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Dear friends,

 

I'm still learning. This is a simple thing.

How can I put inside a function the name of a variable, like the example below.

 

I want to do this:

 

(gen-binary-row 12 '(0 2 5 7 8 11))

>> (1 0 1 0 0 1 0 1 1 0 0 1)

 

But in this way:

 

(setf binrow '(0 2 5 7 8 11))
(gen-binary-row 12 '(binrow))

 

What am I missing ?

 

Thanks for help.

Best,

Julio

You can define local variables within and outside functions with let.

 

In principle, you can also use setf within a function, but then you are overwriting the value of a global variable. In most cases you want to avoid that. Functions that do not change anything outside them (so called side effects) are much safer. 

 

Both let and setf are explained in detail in the very informative online textbook Practical Common Lisp, chapter 6: http://www.gigamonkeys.com/book/variables.html. There you will also learn that Lisp actually distinguishes between lexical and dynamic variables; I was talking here about local and global variables instead for simplicity. In case this chapter covers something you don't follow, just go back a chapter or two and you will learn a lot :)

 

Simple example:


(defun my-function (x)
  (let ((y (+ x 1)))
    y)) 

(my-function 42)
; => 43

 

Best,

Torsten 

But in this way:

(setf binrow '(0 2 5 7 8 11))
(gen-binary-row 12 '(binrow))

What am I missing ?

 

just do it like that:


(setf binrow '(0 2 5 7 8 11))
(gen-binary-row 12 binrow)

;; your "binrow" is now a variable with a LIST as value 
;; when you are writing '(binrow) it will be a LIST with the VALUE binrow (and not the values of "binrow")

 

 

  • Author

Dear Torsten, 

 

Thanks for your thoughtful answer. 

I'm going to try it. 

 

Best 

Julio 

Create an account or sign in to comment


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.