why does this not work? i am trying to create a pattern 1 2 3 4 5 6 which will repeat 6 times. i got this method from my lecturer but it is not working

34 views
Skip to first unread message

Papi London

unread,
Nov 13, 2021, 11:09:54 AM11/13/21
to sage-support
Screenshot (47).png

David Joyner

unread,
Nov 13, 2021, 12:56:26 PM11/13/21
to SAGE support
It seems rep is an R function. If you are in the sage
notebook, you need to make sure your cell is an R cell.
I don't use the notebook much myself, but this:

d <- rep(1:8,6)
d

returns

[1] 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6
[39] 7 8 1 2 3 4 5 6 7 8

Is that what you want?

Not, if you just want to create repetition of a list on the command line,
you can also try list multiplication like this:

sage: [1,2,3]*4
[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]

On Sat, Nov 13, 2021 at 11:09 AM Papi London <abdulra...@gmail.com> wrote:
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/68d5a0fe-e95a-4ab6-9aba-6cdc9942a673n%40googlegroups.com.

Emmanuel Charpentier

unread,
Nov 25, 2021, 3:34:43 AM11/25/21
to sage-support

Sage (i. e. Python) solution : list(range(1,9))*6

HTH,

Le samedi 13 novembre 2021 à 17:09:54 UTC+1, abdulra...@gmail.com a écrit :
Reply all
Reply to author
Forward
0 new messages