Seq_JPH {lazy.symbolic}R Documentation

スマートなシーケンス生成

Description

英語のヘルプファイルは: Seq

Arguments

from

シーケンスの開始値

to

シーケンスの終了値

decreasing

= 1 で降順のシーケンスを生成

Details

この関数は次のように定義されています:

  from-1 + seq_len(max(0, to-from+1))

そのため、from > to の場合、Seq(from, to)numeric(0) を返します。

基本的には以下と同じ挙動です:

Seq <- function(from, to) {
  if (from <= to) {
     return(from:to)
  } else {
     return(numeric(0))
  }
}

Examples

cat("Seq(3,5)\n")
for( i in Seq(3,5) ) print(i)
cat("Seq(5,3)\n")
for( i in Seq(5,3) ) print(i)
cat("seq(5,3)\n")
for( i in seq(5,3) ) print(i)
cat("\nSeq(3,5, decreasing=1)\n")
for( i in Seq(3,5, decreasing=1) ) print(i)
cat("Seq(5,3, decreasing=1)\n")
for( i in Seq(5,3, decreasing=1) ) print(i)


[Package lazy.symbolic version 1.0.0.20250830 ]