Jump to content

Loops/Wrong ranges: Difference between revisions

m
→‎{{header|R}}: Syntax highlighting.
m (→‎{{header|Phix}}: corrected category)
m (→‎{{header|R}}: Syntax highlighting.)
Line 1,722:
=={{header|R}}==
Aside from the second case, this behaviour is explained by two sentences of seq's documentation: "''generates '''from''', '''from'''+'''by''', ..., up to the sequence value less than or equal to '''to'''. Specifying '''to''' - '''from''' and '''by''' of opposite signs is an error.''" As we can see, '''from''' is always included whenever an error is not thrown and '''to''' will be missed if it cannot be reached.
<lang rrsplus>seq(from = -2, to = 2, by = 1)#Output: -2 -1 0 1 2
seq(from = -2, to = 2, by = 0)#Fails: "invalid '(to - from)/by'"
seq(from = -2, to = 2, by = -1)#Fails: As in the notes above - "Specifying to - from and by of opposite signs is an error."
331

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.