Message Boards Message Boards

0
|
1281 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Where to find help with language intro class

Posted 1 year ago

I'm trying to learn the Wolfram language and have started the Introduction course but I'm stuck on chapter 6. The question (6.13) is, "Make a list line plot of the length of the sequence of digits for each of the first 100 squares." Nothing I try seems to work. I thought "First[IntegerDigits[Range[10]^2]]" would do it but all I get is a 1 (I wanted to make sure I got the list first before doing the ListLinePlot. I've tried looking back at the course material, the online book (3rd ed.), and the online help (which I find EXTREMELY poorly done) but can't seem to find the right way. Where can I find better examples similar to the question? Or can someone please explain what it is I'm missing? Thanks in advance!

POSTED BY: Steve Ruzila
2 Replies

Perhaps

Length /@ IntegerDigits[Range[10]^2] (* /@ = Map[] *)

or

Table[Length[IntegerDigits[k^2]], {k, 10}]

if you haven't covered Map[] yet. If you have covered neither Map[] nor Table[], I'm not sure what to suggest (except learn about one or both, of course).

You may have done this. If you look at the output of IntegerDigits[Range[10]^2], you should realize that you need to find the length of each sublist. And Map[] does something to each element in a list, like find the length in the first code above. First[] gives you the first sublist, which is a list of the digits of the number $1$.

POSTED BY: Michael Rogers
Posted 1 year ago

Map hasn't been introduced yet, but using the Table option you posted doesn't provide the right answer either. If I change Length to First...it works! Thank you very much for the help. It's the {k,20} part that I missed.

POSTED BY: Steve Ruzila
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract