{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d9d4db58",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "32"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# How to use functions/packages from book\n",
    "\n",
    "\n",
    "from book.scratch.linear_algebra import dot\n",
    "dot([1,2,3], [4,5,6])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "31aaeb8f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "def dot(v: Vector, w: Vector) -> float:\n",
      "    \"\"\"Computes v_1 * w_1 + ... + v_n * w_n\"\"\"\n",
      "    assert len(v) == len(w), \"vectors must be same length\"\n",
      "\n",
      "    return sum(v_i * w_i for v_i, w_i in zip(v, w))\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# To print the source code:\n",
    "\n",
    "import inspect\n",
    "lines = inspect.getsource(dot)\n",
    "print(lines)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24011290",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
