unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).