您可以在"if"窗口中执行多个语句吗?陈述? [英] Can you execute multiple statements in an "if" statement?

查看:120
本文介绍了您可以在"if"窗口中执行多个语句吗?陈述?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的功能:

(defun MyFunction(input)
  (let ((NEWNUM (find input num)))
    (if (find input num)              //if this 
      (setq num NEWNUM) (FUNCT2)      //then execute both of these
    (list 'not found))))              //else output this

因此,在if语句之后,我希望能够先执行(setq num NEWNUM),再执行(FUNCT2),以便设置新变量,然后调用函数.有关如何执行此操作的任何想法?

So after the if statement I want to be able to execute (setq num NEWNUM) followed by (FUNCT2) in order to set a new variable and then call a function. Any ideas on how to do this?

推荐答案

要依次执行几件事,您需要progn.

To do several things in sequence, you want progn.

(defun MyFunction(input)
  (let ((NEWNUM (find input num)))
    (if (find input num)              //if this 
      (progn 
        (setq num NEWNUM)
        (FUNCT2))      //then execute both of these
    (list 'not found))))              //else output this

这篇关于您可以在"if"窗口中执行多个语句吗?陈述?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆