Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.2K Views
|
1 Reply
|
1 Total Like
View groups...
Share
Share this post:

Writing a function that will take lists and return the list lengths?

Posted 10 years ago

This seemed like a much easier idea in my head than it was to actually implement into Mathematica ..

This is what I have so far, it is obviously wrong..

Clear[findlength, h]
findlength[x___] := h[x] /. {List -> Length[h[x]], h -> List};
findlength[{x, y, z}, {4, 2}]

I also tried something along the lines of this, which is also wrong..

Clear[findlength]
findlength[x___] := {x} /. {List -> Length[{x}]}
findlength[{c, s, d, a}, {4, 2, 5}]

The outputs for both are quite strange. I'm very new to "rules" but I feel like I am certainly on the right track.

Any suggestions or advice is always appreciated

B

POSTED BY: Brandon Davis
Posted 10 years ago
POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard