{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "36" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "3^2^1^5+3^3" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Int64" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "typeof(3^2^1^5+3^3)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "36\n" ] } ], "source": [ "println(\"$(6*6)\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "36\n" ] }, { "data": { "text/plain": [ "Nothing" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "typeof(println(\"$(6*6)\"))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "240" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "2^2^3-2^4" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "48" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(2^2)^3-2^4" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(5 - 7) * 2 + 4" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "false" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1 + 3 < 5 && 2^2 === 4.0" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "false" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "2^2 === 4.0" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "false" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = 4\n", "\n", "x > 0 && x <= 3" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "true" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "((true && false) && false) || true" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "false" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(true && false) && (false || true)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "true" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "true && ((false && false) || true)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "15×2 Array{Float64,2}:\n", " 1.68005 -1.6417 \n", " 0.501309 -0.977698\n", " 1.52801 0.527711\n", " 1.70012 1.71152 \n", " 1.99249 1.891 \n", " 2.70608 -0.463428\n", " 2.99493 -0.443567\n", " 3.49185 -1.27518 \n", " 3.50119 -0.6905 \n", " 4.45992 -5.51613 \n", " 4.93697 -6.0017 \n", " 5.02329 -8.36417 \n", " 5.04234 -7.92448 \n", " 5.50739 -10.7748 \n", " 5.56867 -10.9172 " ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data = [1.6800483 -1.641695388; \n", " 0.501309281 -0.977697538; \n", " 1.528012113 0.52771122;\n", " 1.70012253 1.711524991; \n", " 1.992493625 1.891000015;\n", " 2.706075824 -0.463427794;\n", " 2.994931927 -0.443566619;\n", " 3.491852811 -1.275179133;\n", " 3.501191722 -0.690499597;\n", " 4.459924502 -5.516130799;\n", " 4.936965851 -6.001703074;\n", " 5.023289852 -8.36416901;\n", " 5.04233698 -7.924477517;\n", " 5.50739285 -10.77482371;\n", " 5.568665171 -10.9171878]" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "15-element Array{Float64,1}:\n", " 1.6800483 \n", " 0.501309281\n", " 1.528012113\n", " 1.70012253 \n", " 1.992493625\n", " 2.706075824\n", " 2.994931927\n", " 3.491852811\n", " 3.501191722\n", " 4.459924502\n", " 4.936965851\n", " 5.023289852\n", " 5.04233698 \n", " 5.50739285 \n", " 5.568665171" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data[:,1]" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "coordinates (generic function with 1 method)" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function coordinates(x, y, z)\n", " if x==0 && z == 0 && y==0\n", " println(\"origin\")\n", " else\n", " println(\"($x, $y, $z)\")\n", " end\n", "end" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(0, 0, 2)\n" ] } ], "source": [ "coordinates(0,0,2)" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "origin\n" ] } ], "source": [ "coordinates(0,0,0)" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(19, 3)" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a, b = 2, 3 \n", "function f(x) \n", " b = 5 \n", " a*x + b\n", "end\n", "f(7), b" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "f (generic function with 1 method)" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function f(x)\n", " return 2x\n", " 3x\n", " print(\"5\")\n", "end" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "10" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f(5)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Julia 1.2.0", "language": "julia", "name": "julia-1.2" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.2.0" } }, "nbformat": 4, "nbformat_minor": 4 }