all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Function that changes value of a variable
@ 2022-08-21  0:54 wilnerthomas--- via Users list for the GNU Emacs text editor
  2022-08-21  2:04 ` [External] : " Drew Adams
  2022-08-21  2:40 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 7+ messages in thread
From: wilnerthomas--- via Users list for the GNU Emacs text editor @ 2022-08-21  0:54 UTC (permalink / raw)
  To: Help Gnu Emacs

I am trying to change the value a a variable with the following function, but is not working as intended.

(defun constrain (var min-n max-n)  "Ensure that value of var is between MIN-N and MAX-N inclusive by constraining."  (cond   ((< var min-n)  (setq var min-n))   ((> var max-n)  (setq var max-n))   ((eq var t)     (setq var 1))   ((eq var nil)   (setq var 0))))
Have done the following test, but the value stays 21.

(defvar pingu 21)
(constrain pingu 0 8)
(message "%d" pingu)



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-08-22 14:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-21  0:54 Function that changes value of a variable wilnerthomas--- via Users list for the GNU Emacs text editor
2022-08-21  2:04 ` [External] : " Drew Adams
2022-08-21  2:40 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-08-21  3:31   ` wilnerthomas--- via Users list for the GNU Emacs text editor
2022-08-21 13:47     ` [External] : " Drew Adams
     [not found]     ` <SJ0PR10MB5488C4F9BF7E4F324B57C6F3F36E9@SJ0PR10MB5488.namprd10.prod.outlook.com-NA-eKDt----2>
2022-08-21 23:18       ` wilnerthomas--- via Users list for the GNU Emacs text editor
2022-08-22 14:21         ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.