0
votes
1answer
76 views

How can I represent this automorphism of Q(i,a)?

Let $a$ represent some real irrational number. I am trying to perform computations with an automorphism $f:\mathbb{Q}(i,a)\to\mathbb{Q}(i,a)$ which fixes $\mathbb{Q}(i)$ pointwise and maps $a$ to $i ...
2
votes
1answer
111 views

Function to differentiate between date pattern and specific string format

I'd like to write a function that behaves one way when the argument is a Mathematica date, such as {2013,12,15}, or with added hours, minutes and seconds if ...
1
vote
0answers
32 views

Pattern matching list elements in pure functions [duplicate]

Pattern matching here is a functional programming term, but it might be called differently in Mathematica, I'm not sure. It is possible to match the elements of the list in a regular function ...
17
votes
1answer
183 views

How to get Cases to wrap results in an arbitrary head?

A number of functions provide for results to be wrapped in an arbitrary head. This is very important in cases where the results should not be evaluated. Take ...
2
votes
1answer
114 views

Flat function with repeated sequence

There are functions like Join[ ] that accept a variable number of arguments. Join is a flat function, as the order of arguments ...
1
vote
2answers
106 views

Named patterns as function argument descriptors

I have a function timeToMinutes that takes a 24-hour time as a string argument (in digital clock format, e.g., "15:47") and converts it to the number of minutes ...
3
votes
1answer
142 views

Downvalues vs. Scoping for Functions

Regarding my recent question on using a default value for a function argument when a pattern was not met yielded some interesting answers, but the general consensus was "Yes this can be done, but ...
6
votes
4answers
462 views

Function argument to default under certain condition

Inspired by this and this question (and how I handle this in practice), what is the best way to default a function value when a certain condition is met? For example, if a function is defined as: ...
8
votes
2answers
739 views

Determine whether some expression contains a given symbol

Given a symbol t and an expression expr, how can I determine whether or not the symbol t ...
14
votes
6answers
2k views

Counting negative values in list

I would like to count the negative values of a list. My approach was Count[data, -_] which doesn't work. How can I tell Mathematica to count all numbers with ...
11
votes
4answers
469 views

Assessing argument type in set delayed function definitions

I'm wondering how to properly assess the type of arguments passed to functions defined with :=. I want my functions to be the most efficient, unambiguous and clear ...