You are not logged in.
Did I? Well I never!
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
Yes, the select command is a big one. You used a pure function # and &, that is from the lambda calculus.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
That's a bit heavy for this lightweight. I copied the formula from the Help files, and I don't know (yet) what those functions actually do.
I remember using the double '&&' in my YOB puzzle solution and knew then what it did, but I don't know what a single '&' does.
I don't know any calculus, other than what you said I now 'know'.
Last edited by phrontister (2012-05-07 22:40:18)
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
# this is a slot operator, & this is the end of the operation or function.
Select[{1,2,3,4,5,6},#>5&]
Will yield just 6. Do you see why?
I don't know any calculus, other than what you said I now 'know'
If you can use M you know more calculus than I could ever hope to.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
I don't know the term 'slot operator' , or what # really does. I remember using # for alphametics solutions.
'6' is the element selected from the list by the '>5' constraint, which omits all numbers <=5. Same as in my use of Select for juan's problem.
Last edited by phrontister (2012-05-07 23:13:09)
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
The Select operator in this case goes down the list and picks them one at time and puts them in the slot ( # ) 1 > 5, 2 > 5, 3>5, 4>5, 5>5, 6>5. Only the 6>5 is true so that is the one that is returned. The #>5& is called a pure function because it has no name for itself or its parameters.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Is the slot operator like the mapping operation I used earlier with FromDigits /@ Permutations?
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
Mapping is different. Mapping (/@) takes any function like FromDigits or one you write yourself and spreads it to every element of the list.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Oh, I see. A kind of similar action with different tools.
The #>5& is called a pure function because it has no name for itself or its parameters.
I had no idea what 'pure function' meant. I thought it could be some highfalutin term like 'pure maths'!
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
Hi;
Not exactly similar. I have corrected post # 56 to be accurate. That will help.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Not exactly similar.
I was really only referring to the fact that they both act on each element in the list...but I suppose there are many other commands that do too.
What is a 'slot'? Is it an area into which elements (for example) are put to facilitate performing some action on them?
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
I meant to tell you I used the wrong word in post #56. I meant Select, not slot.
Yes, the slot can be thought of as a generic variable. Data is put into it.
In other laguages you would have had to make up a function and given it a name. For instance
test(n)= If n>5 return n
That function ( in some language) when you put in test(6) it would return a 6. The pure function #>5& did the same thing but you did not have to name the input or the function.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Ah, yes. That clears that up. I hadn't worked out what it was that you'd corrected.
...generic variable
That reminds me of the '@' in BASIC, which allows you to use a single array without having to DIM it like you'd have to with variable letters.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
Hi phrontister;
Have fun with M. You are doing well with it. It is a little different but I like the fact that all the commands can map themselves over lists. Some like Sine do that automatically
Sin[{1,2,3,4,5}] will output,
see how Sine has wrapped itself around each element? No more loops!
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Hi Bobby,
I didn't know the extent of the mapping effect.
Here's one I got to work:
In[1]:= Total[N[Sqrt[{1, 2, 3, 4, 5}]]]
Out[1]= 8.38233
The range of stuff you can do with M is staggering!!!
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
Hi phro
Look at bobbym's problem in Bafflers with sqare root. Tell me if M works it out.
Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Hi;
The range of stuff you can do with M is staggering!!!
Yes, it makes me look good, that is staggering in itself.
N[Sqrt[Range[5]],50]//Total
yields
8.3823323474417620387383087344468466809530954887989
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
A little tweak:
In[1]:= N[Total[Sqrt[{1, 2, 3, 4, 5}]], 50]
Out[1]= 8.3823323474417620387383087344468466809530954887989
The list is endless! And the calcs are so quick!
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
We think alike, look at my post above you!
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Hey! Did you see my post and copy it, and then snuck it in before mine (with a customised post time)??!
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
No, I did not but it is spooky!
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
I now believe in ESP!
You introduced Range. I remember coming across that earlier today but didn't think to use it here.
What does '//' do? Is there an advantage using that option instead of mine?
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
Yes you do not have to match brackets or type them. Sometimes bracket matching is a pain.
100! //N is the same as N[100!]
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Yes, I see. Thanks.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online
Hi stefy,
Just looking at that problem now...
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Online