匿名函数返回1使用#() [英] Anonymous function returning 1 using #()
本文介绍了匿名函数返回1使用#()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用defn或fn,很容易创建一个函数,它接受一个忽略它并返回1的参数:
Using defn or fn it's easy to create a function that taking one argument that ignores it and returns 1:
(defn ret1 [arg] 1)
(fn [arg] 1)
这是用#()宏吗?我不是指使用丑陋或欺骗像
Is it possible to do this with the #() macro? I don't mean using something ugly or "cheating" like
#(/ % %) or
#(if (nil? %) 1 1)
我的意思是逐字地忽略参数并返回1.我可以
I mean literally ignoring the parameter and returning 1. I can't find a clean syntax that works.
推荐答案
这篇关于匿名函数返回1使用#()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文