-1

I would like R to be more pythonic. One of the steps for transforming it would be the use of 'not' instead of '!'. I hope this does not need writing of C++ and compiling etc, or does it?

Functionality: "!TRUE" should equal "not TRUE".

If you know where to start, please point me there.

4

1 回答 1

13

您最好采用 R 方式。为什么要为这么一件小事费尽心思?如果您想要 Python,请坚持使用 Python。!此外,在其他编程语言中充当“不”是很常见的。

无论如何,这是允许使用“not”的东西,但它会涉及括号(Arrr!方式)

not <- function(x) { !x }

if (not(FALSE)) { print(1) }
[1] 1 

在我看来,这比!.

我可以听到你在想“但我想拥有if x is not in y:”,但是拜托,这与建议我想要一种让 Python 不需要缩进的方法是一样的。

这个想法是你学习一种语言,你不会改变一种语言来适应个人的需要。其他人使用您的代码会发生什么?

于 2013-11-24T15:50:39.003 回答