Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  variables-and-objects.ipynb   Sprache: unbekannt

 
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1023ec3f",
   "metadata": {},
   "source": [
    "### Variables and Objects\n",
    "In GAP (and most other programming languages), constants always have the same meaning. On the other side of things are variables, which have an associated identifier and a meaning that depends on what has been assigned to them.\n",
    "\n",
    "Assignments are done in GAP using the `:=` operator, with the identifier of the variable on the left and the value/object to be assigned on the right. Almost any GAP object can be assigned to a variable. After assignment, the variable will evalute to that object if evaluated. As such, it is possible to refer to the object by the name of the variable in any situation:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f25c63ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 3,
     "metadata": {
      "text/plain": ""
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a := 9 - 7;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7379987a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 4,
     "metadata": {
      "text/plain": ""
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a + 4;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "62762ac2",
   "metadata": {},
   "source": [
    "After an assignment, the value/object of the assigned variable is printed. This printing can be prevented by doubling up the semicolon at the end of the assignment command:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "44d0f53f",
   "metadata": {},
   "outputs": [],
   "source": [
    "b := 22;;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "361d9381",
   "metadata": {},
   "source": [
    "In Jupyter, variable assignments are kept across cells. As such, the variables defined earlier will be accessible in cells run after, and can be accessed or reassigned as necessary."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "83f675ff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "24"
      ]
     },
     "execution_count": 6,
     "metadata": {
      "text/plain": ""
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a + b;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eb591787",
   "metadata": {},
   "source": [
    "GAP also contains a number of pre-defined variables. You can get an overview of all the current variables in GAP by entering the function `NamesGVars()`. Many of these are predefined by the GAP kernel:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "2306161f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
--> --------------------

--> maximum size reached

--> --------------------

[ Dauer der Verarbeitung: 0.41 Sekunden  (vorverarbeitet)  ]

                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge