Mathematica pseudo-types Integer, Real, Rational, Complex, String and Symbol, and their use.

learn more… | top users | synonyms

92
votes
7answers
10k views

Struct equivalent in Mathematica?

I really miss having something like a struct in Mathematica. I know of (and regularly use) a couple of programming techniques which feel like a ...
28
votes
4answers
2k views

How to create strong types?

In a program I'm writing, I create a list of lists, that looks something like this: {{100, {1,2,3,4,5}}, {105, {2,4,6,8}}, {42, {42,39,56}}} I then pass this ...
17
votes
6answers
4k views

How to check if an expression is a real-valued number

What is a simple, fast way to test whether an expression is a real-valued number? I ask since there is no RealQ function. If we call this test ...
17
votes
0answers
139 views

V10's TypeSystem - what are these function useful for? [closed]

The symbols in the TypeSystem` context are clearly used for working with Datasets, but they seem powerful. I was hoping that someone could help explain how they work and is they are useful for ...
12
votes
3answers
263 views

Find all heads a function is defined on

So say I've got a function g defined as follows: g[x_Integer] := x + 1 g[s_String] := s <> "!!!" How would I write a ...
8
votes
1answer
2k views

Get expression type?

Is there a built in function that distinguishes between different kinds of variables? I mean something like: ...
6
votes
2answers
202 views

Get information about a stack of images, without plotting it

A very long time ago I used Mathematica for a few months and found it very intuitive. Now for my work I use MatLab. I was just trying some stuff out with Mathematica again and there is something I ...
6
votes
3answers
253 views

Does there exist any way to add type annotations?

Is there any way to add my own annotations to values or functions in Mathematica? Imagine, for example, that I wanted to annotate a List specifically as a ...
5
votes
1answer
91 views

Determine return type of CompiledFunction expression

Is there a way to extract the types of the arguments and the return type from a CompiledFunction expression? I am writing a package for code generation (basically a wrapper around CCodeGenerate) where ...
5
votes
1answer
134 views

Behavior of 1.2 ∈ Rationals changes in v9?

A friend of mine using version 9 recently showed me this: It's strange because in version 8.0.4 1.2 ∈ Rationals does return ...
4
votes
2answers
66 views

Type error before replacement rule is applied

When I type a <> "0" /. {a -> "1"} I get the error ...
4
votes
1answer
40 views

Relative factorisation with scalar quantities

I'd like to find a natural way to tell mathematica that a given unknown in a polynomial should be treated as a number, unlike the other variables. Typically I'd like to sum two polynomials in several ...
3
votes
1answer
108 views

Immutability, Association and typing

I have read the article by Leonid on the question. I am still struggling. I am trying to use Association to inject some pseudo-typing in my code. Here is my ...
3
votes
1answer
128 views

Datatypes and numbers in Mathematica

I have some questions about numbers in Mathematica: Does Mathematica work with datatypes like int, long, ...
3
votes
1answer
113 views

Using less memory to store and manipulate specific types

Is there a simple way to use Integer types (in particular, a table of Integer types) that require only 4 or 8 bytes (reps. 32 and 64 bits) representation? It seems that integers in Mathematica have a ...
3
votes
1answer
92 views

.NET link - index of property

I have a property in .NET Type, which is actually a generic list of objects. When I try access the property using numeric index e.g. 10, this works. However when I iterate through indices using ...
2
votes
2answers
149 views

How to get the type of an object

I'm looking for a way to get the type of an object: TypeOf["x"] -> String TypeOf[1] -> Integer Or something along those lines.
2
votes
1answer
82 views

Type declaration for list arguments

How can I make f[n_Integer]=2*n valid for a list of integers? For example: f[nlist_Integer] := 2*nlist[[1]] does not work ...
2
votes
3answers
445 views

What format to use to store expressions in database?

I am storing lists of expressions into a MySQL database. Each list is of form {_String, {_String, _Real}, _Real} What data format should each column of the ...
1
vote
1answer
135 views

How to convert a column of a Dataset into a list [closed]

I'm loving the fact that Mathematica has finally implemented the Dataset feature, but I'm still struggling a little with it. I have a Dataset that contains a bunch of functions for different diseases ...
1
vote
1answer
134 views

Declare type in InputField

Is it possible to declare a type in InputFunction to only accept positive Integers as input? I know i can create an ...
1
vote
1answer
58 views

Control data type (or precison?) to limit memory usage

I couldn't find the answer to my question, so here it is: I have quite a large table, which I generate in Matlab (for some reasons i use both Matlab and Mathematica, I'd like to use only one of them, ...
1
vote
0answers
54 views

Compilation error: “Could not complete external evaluation at…”

I'm pretty new to trying to use Compile[], and I just can't see why I'm getting this error. I have two functions to define beforehand; one of them is a bit odd: <...
1
vote
0answers
50 views

Pattern type and list indexing warnings/errors

I'm new to Mathematica and am trying to implement some simple noise functions in it in hopes of eventually finding an integral for them. This is the interesting part of the code: ...
1
vote
0answers
66 views

How can I perfect this game for Wolfram Demonstration publication? [closed]

When the messages change the window inactivates, and when I try to host an interactive CDF on my site it turns red and says something about numbers having to be scaled or offset. Any help? I'm ...
0
votes
1answer
575 views

Mathematica command for type checking?

I have a program where users can enter mathematica commands that can evaluate to any of the standard numeric types (complex, real, int, etc.), or to boolean values. Moreover the users can enter ...