{
"cells": [
{
"cell_type": "markdown",
"id": "227830f1",
"metadata": {},
"source": [
"# cnt001_basictseq\n",
"Example showing possible usages of the TSeq class.\n",
"\n",
"\n",
"\n",
"\n",
"**Author:** Danilo Piparo \n",
"This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, March 19, 2024 at 07:06 PM."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "d466f1bb",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:06:29.077972Z",
"iopub.status.busy": "2024-03-19T19:06:29.077597Z",
"iopub.status.idle": "2024-03-19T19:06:30.412122Z",
"shell.execute_reply": "2024-03-19T19:06:30.389313Z"
}
},
"outputs": [],
"source": [
"using namespace ROOT;"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "02013192",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:06:30.419989Z",
"iopub.status.busy": "2024-03-19T19:06:30.419560Z",
"iopub.status.idle": "2024-03-19T19:06:30.629828Z",
"shell.execute_reply": "2024-03-19T19:06:30.628677Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loop on sequence of integers from 0 to 10\n",
"Element 0\n",
"Element 1\n",
"Element 2\n",
"Element 3\n",
"Element 4\n",
"Element 5\n",
"Element 6\n",
"Element 7\n",
"Element 8\n",
"Element 9\n"
]
}
],
"source": [
"cout << \"Loop on sequence of integers from 0 to 10\" << endl;\n",
"for (auto i : TSeqI(10)) {\n",
" cout << \"Element \" << i << endl;\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "a044e8ca",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:06:30.634435Z",
"iopub.status.busy": "2024-03-19T19:06:30.634064Z",
"iopub.status.idle": "2024-03-19T19:06:30.838961Z",
"shell.execute_reply": "2024-03-19T19:06:30.837820Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loop on sequence of integers from -5 to 29 in steps of 6\n",
"Element -5\n",
"Element 1\n",
"Element 7\n",
"Element 13\n",
"Element 19\n",
"Element 25\n"
]
}
],
"source": [
"cout << \"Loop on sequence of integers from -5 to 29 in steps of 6\" << endl;\n",
"for (auto i : TSeqI(-5, 29, 6)) {\n",
" cout << \"Element \" << i << endl;\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "fafbbfa6",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:06:30.843163Z",
"iopub.status.busy": "2024-03-19T19:06:30.842748Z",
"iopub.status.idle": "2024-03-19T19:06:31.047657Z",
"shell.execute_reply": "2024-03-19T19:06:31.046453Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loop backwards on sequence of integers from 50 to 30 in steps of 3\n",
"Element 50\n",
"Element 47\n",
"Element 44\n",
"Element 41\n",
"Element 38\n",
"Element 35\n",
"Element 32\n"
]
}
],
"source": [
"cout << \"Loop backwards on sequence of integers from 50 to 30 in steps of 3\" << endl;\n",
"for (auto i : TSeqI(50, 30, -3)) {\n",
" cout << \"Element \" << i << endl;\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "4ef6afc7",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:06:31.067154Z",
"iopub.status.busy": "2024-03-19T19:06:31.066718Z",
"iopub.status.idle": "2024-03-19T19:06:31.272949Z",
"shell.execute_reply": "2024-03-19T19:06:31.271759Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"stl algorithm, for_each\n",
"For each: 2\n",
"For each: 5\n",
"For each: 8\n",
"For each: 11\n",
"For each: 14\n",
"For each: 17\n",
"For each: 20\n",
"For each: 23\n",
"For each: 26\n",
"For each: 29\n",
"Random access: 3rd element is 8\n"
]
}
],
"source": [
"cout << \"stl algorithm, for_each\" << endl;\n",
"TSeqUL ulSeq(2,30,3);\n",
"std::for_each(std::begin(ulSeq),std::end(ulSeq),[](ULong_t i){cout << \"For each: \" << i <