New answers tagged

5

Many of Mathematica's built-in functions have the property that when they are applied on a list they automatically are applied on all the elements of the list. Log[{1, 2, 3}] {0, Log[2], Log[3]} This property is called Listable: Attributes[Log] {Listable, NumericFunction, Protected} User-defined functions do not have this by default (although if ...


12

Most of the issue here is related to subtle evaluation and pattern-matching features in Haskell that have no analog in Wolfram Language (WL). The ~ operator has no real equivalent within WL. Nevertheless, the issues can be approximated in WL and such approximation will indeed make judicious use of Hold attributes to induce lazy evaluation semantics. The ...


4

You could define symbol[___]:=$Failed For every existing symbol from Names["`*"] or for all that will be created by using $NewSymbol. But I would not do that globally. There are many use cases for custom expressions that are 'unevaluated' see for example: 11436 What I do is to associate symbol[___]:=$Failed when I define a function. I do this so often ...


7

The following function checks whether an expression contains anything of the form f_[___] (i.e. an unevaluated function call), where f is a symbol in the current context1 (to ensure that e.g. Sin[3] is allowed): functioncall::unev = "Unevaluated function calls!"; check = If[ ! FreeQ[#, x_Symbol[___] /; Context@x == $Context, All], Message[...


Top 50 recent answers are included