id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
sequencelengths
1
47
36,177
fuselage-example.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/fuselage-example.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object fuselage-example (slide-show-leaf) :computed-slots ((slide-data `( (:title "Single cylinder" :bullet-points ((:description "Start with a single cylinder:" :examples ((:code (setq *brep-isos-default* '(:n-u 8 :n-v 8))) (:define-object fuselage-cylinder))) (:description ,(string-append "In ta2 with a trimetric view: " (with-cl-who-string () ((:img :src "/g102/images/fuselage-cylinder.png"))))))) (:title "Single cone" :bullet-points ((:description "Now add a single cone:" :examples ((:define-object fuselage-cone))) (:description ,(string-append "In ta2 with a trimetric view: " (with-cl-who-string () ((:img :src "/g102/images/fuselage-cone.png"))))))) (:title "Excercise: Construct a fuselage using cylinder and cones" :bullet-points ((:description "Create a class that resembles an airliner's fuselage, using cylinder-solid and cone-solid. To do this, set up a define-object that has these primitives as children (in it's ':objects'-slot)" ) (:description "Make use of the ':center' input-slots on both the cylinder-solid and cone-solid to position them in space" ) (:description "Add input-slots to your fuselage class that allow total length and diameter to be specified. Make sure that any possible combination of input values results in a proper fuselage (i.e. the individual children must always be connected)" ) (:description ,(string-append "You should end up with something like this:" (with-cl-who-string () ((:img :src "/g102/images/fuselage.png"))))) ))))))
2,664
Common Lisp
.lisp
59
39.169492
244
0.683223
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8a686423dcff0a83d869c3aa67c10f2a8eed5a10e4ecd0002c3e7aeb532fdce1
36,177
[ -1 ]
36,178
debugging.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/debugging.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (Gendl). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object debugging (slide-show-leaf) :computed-slots ((strings-for-display "Debugging") (slide-data `((:title "Basic Tips" :bullet-points ((:description "<a href=\"http://www.youtube.com/user/GDLTutorials\">GDLTutorials</a> video for Compile Errors") (:description "Stay tuned for video on Runtime Errors") (:description "Basic debugging technique is command-line evaluation") (:description "When some message or geometry object gives an error, evaluate the messages or objects on which it depends") (:description "Continue stepping backwards, doing evaluations, until you isolate the error")))))))
1,580
Common Lisp
.lisp
37
39.216216
80
0.733377
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
9900bc0cd86624dc94358f7d1a0e203ace97b5b22d0b7f40d3847876e7759b81
36,178
[ -1 ]
36,179
assembly.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/assembly.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (Gendl). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object assembly (slide-show-node) :input-slots ((title "G102: Gendl Quickstart") (slide-package (find-package :training-g102)) (image-base-url "/g102/images/") (images-path *images-path*) (style-url "/static/gwl/style/top.css")) :objects ( (introduction :type 'introduction) (objects :type 'objects) (geometry :type 'geometry) (tower-example :type 'tower-example) (user-interface :type 'user-interface) (outside-world :type 'outside-world) (debugging :type 'debugging) (future :type 'future))) #| To Do: x Change font to Courier for command-line examples. x Add make-self example. x Change hello-jake example to aero function. x get rid of keyword symbols on messages where not needed e.g. hairy-calc. x check ordering example on hairy-calc. o check Ackermann example x check City example o check Primi Plane example o prepare VRML format for cone and cylinder. |#
1,831
Common Lisp
.lisp
50
34.12
74
0.752137
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a6e7747edc81ea41c1c05bc4e79c3a86877870f3c8b7b9c31f3c80f999c00550
36,179
[ -1 ]
36,180
future.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/future.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (Gendl). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object future (slide-show-leaf) :computed-slots ((strings-for-display "Future") (slide-data `((:title "Continuing to Expand" :bullet-points ((:description "Generative KBE Concept (based on Lisp) has been around since 1984") (:description "Still revolutionary and disruptive to many established players: development tools, traditional CAD systems, even ERP systems") (:description "KBE will evolve (multi-core multi-processing, handheld client devices) but I predict it will still be around in a recognizable form 50 years from now.")))))))
1,548
Common Lisp
.lisp
35
39.885714
82
0.72141
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
208ef193d75012e4f48ded7df0bc3ae56633205ade007b8e042b01d71284c630
36,180
[ -1 ]
36,181
outside-world.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/outside-world.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (Gendl). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object outside-world (slide-show-leaf) :computed-slots ((strings-for-display "Outside World") (slide-data `((:title "2D Drawings" :bullet-points ((:description "<span class=gdl-object-def>base-drawing</span> represents a physical sheet of paper with <span class=gdl-message-name>width</span> and <span class=gdl-message-name>length</span> measured in <i>points</i> (72 per inch, 28.29 per centimeter) and zero <span class=gdl-message-name>height</span>.") (:description "<span class=gdl-object-def>base-view</span> represents one rectangular area contained within a sheet.") (:description "<span class=gdl-object-def>base-view</span> cannot exist on its own, it must be within the context of a drawing.") (:description "Only the full drawing of type <span class=gdl-object-def>base-drawing</span> can can be viewed in Tasty (with Add Node in Top view) or outputted -- instances of <span class=gdl-object-def>base-view</span> cannot be drawn or outputted on their own.") (:description "<span class=gdl-object-def>base-view</span> takes a list of <span class=gdl-message-name>objects</span> (their selves are included) <span class=gdl-message-name>object-roots</span> (their leaves are included).") (:description "Other optional input-slots to base-view include: <dl> <dt><span class=gdl-message-name>projection-vector</span> <dd>defaults to <span class=lisp-code>(getf *standard-views* :top) <dt><span class=gdl-message-name>view-scale</span> <dd>defaults to a scale which fits the objects in the view <dt><span class=gdl-message-name>width</span> and <span class=gdl-message-name>length</span> <dd>default to <span class=gdl-message-name>width</span> and <span class=gdl-message-name>length</span> from the drawing. </dl>"))) (:title "Example Drawings" :bullet-points ((:description ,(format nil "Wing Drawing (click <a href=~awing-drawing.pdf>here</a> to view sample)" (the image-base-url)) :examples ((:define-object wing-drawing))) (:description ,(format nil "Wing Drawing with Dimension (click <a href=~awing-drawing-with-dimension.pdf>here</a> to view sample)" (the image-base-url)) :examples ((:define-object wing-drawing-with-dimension :image-url "wing-drawing-with-dimension.pdf"))) (:description ,(format nil "Wing Drawing with Typeset Block (click <a href=~awing-drawing-with-typeset-block.pdf>here</a> to view sample)" (the image-base-url)) :examples ((:define-object wing-drawing-with-typeset-block) (:define-object wing-drawing-typeset-block))))) (:title "PDF and PNG output" :bullet-points ((:description "2D formats only work on Drawings, not on 3D geometry") (:description "You can call the <span class=gdl-message-name>cad-output</span> <span class=gdl-section-keyword>:output-function</span> to output the drawing in PDF, PNG, JPEG, DXF, or Raphael format" :examples ((:define-object wing-drawing-with-output))))) (:title "Iges/STEP/native output" :bullet-points ((:description "You can output 3D geometry directly in these formats") (:description "Use <span class=gdl-message-name>cad-output</span> for the self, and <span class=gdl-message-name>cad-output-tree</span> for the leaves." :examples ((:define-object wing-with-iges-and-step))) (:description "Output is flat collection of entities; assembly hierarchy output is under development."))) (:title "Streaming Output from a Web Page" :bullet-points ((:description "You publish a URL (web address) with a <span class=lisp-code>:path</span> (the actual web address) and a <span class=lisp-code>:function</span> (the function which responds to requests made of that address)") (:description "The response function should write the data to the <span class=lisp-code>request-reply-stream</span>, using the applicable Gendl format and <span class=gdl-message-name>output-function</span>") (:description "The slot which contains the URL should do the publishing, then return the URL for use in laying out the actual web page" :examples ((:define-object wing-with-iges-download :include-page-link? t) (:define-object wing-drawing-with-input-airfoil))))) (:title "Iges/STEP/native input" :bullet-points ((:description "Readers are objects of type <span class=gdl-object-def>iges-reader</span>, <span class=gdl-object-def>step-reader</span>, and <span class=gdl-object-def>native-reader</span>." :examples ((:define-object wing-readers))) (:description "If you want to save geometry for yourself or exchange with other Gendl users, use the native format and \".iwp\" file extension.") (:description "The readers yield a flat list of entities currently; Assembly tree and attribute readers and direct Catia/ProE/UG readers are under development."))) (:title "Reading Lisp data from a File" :bullet-points ((:description "If your data is already formatted as lists (or one big list) in a text file, then nothing can be easier than reading it into Lisp:" :examples ((:code (with-open-file (in "my-file-name.lisp") (read in))))))) (:title "Reading Text data from a File" :bullet-points ((:description ,(format nil "See this <a href=~afile-IO.pdf>section of your course manual</a> which discusses reading points data from a file." (the image-base-url))) (:description "A few notes about this manual section: <ul> <li>The double-backslash is <i>not</i> the most foolproof pathname naming scheme in Common Lisp. It will break on Linux and MacOS. The most foolproof naming scheme is to use proper CL pathnames (created with functions such as <span class=lisp-code>make-pathname</span>, <span class=lisp-code>merge-pathname</span>, etc.) <li>A more convenient approach might sometimes be to use Unix-style forward slashes (e.g. \"/foo/bar/goo.txt\"). These will also work on Windows. <li>If you have control over your file formats, it is almost always best to use a \"Lispy\" format to store your data, because you have a built-in Lisp parser always available in Lisp. In this format you can read in your data with a simple call to <span class=lisp-code>read</span>. </ul> "))) (:title "Other outside world interface examples" :bullet-points ((:description "Relational Database interface (ODBC, MySQL, Oracle)") (:description "Webserver (allegroserve) and Web client (allegroserve client)") (:description "XML and HTML parsers and generators") (:description "JSON, Javascript (cl-json, cl-parenscript)") (:description "C and FORTRAN foreign-function interface"))) (:title "<i>Exercise 13</i>" :bullet-points ((:description "Modify your airfoil exercise to read its points from a Lisp-formatted external file.") (:description ,(format nil "Modify your airfoil exercise to read its points from a plain text external file, as described in the <a href=~afile-IO.pdf>course manual</a>." (the image-base-url)))))))))
8,642
Common Lisp
.lisp
183
40.300546
88
0.688695
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
62764ea050d35bb4f5da6a4707dbc3556f19b4cdfc2b2c7ab39e49416305f0fb
36,181
[ -1 ]
36,182
session-02.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/session-02.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (Gendl). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object objects (slide-show-leaf) :computed-slots ((strings-for-display "Functions as Objects") (slide-data `((:title "Function" :bullet-points ((:description "A machine which accepts some Input then yields a defined Output" :image-url "function-machine.jpg" :image-caption "A Function Machine <small><i>(image from http://wbadvies.nl)</i></small>") )) (:title "Calling Functions in Common Lisp" :bullet-points ((:description "Function Call is expressed as a List expression (a.k.a. \"Symbolic EXPression\" or \"S-exp\")") (:description "Function name first, then arguments, separated by spaces") (:description "For example, we feed <span class=lisp-code>2</span> and <span class=lisp-code>2</span> into the function <span class=lisp-code>+</span> to yield the result which is <span class=lisp-code>4</span>." :examples ((:code (+ 2 2) :return-value 4))) (:description "The multiply function (<span class=lisp-code>*</span>) applied to <span class=lisp-code>3</span> and <span class=lisp-code>3</span>" :examples ((:code (* 3 3) :return-value 9))) (:description "The <span class=lisp-code>string-append</span> function applied to three strings" :examples ((:code (string-append "hey" " " "now") :return-value "hey now"))) )) (:title "Defining and Using Custom Functions in Common Lisp" :bullet-points ((:description "Use the operator <span class=lisp-code>defun</span>, followed by name, argument list, and body." :examples ((:code (defun square (number) (* number number)) :return-value square))) (:description "Now you can call it just like any other function" :examples ((:code (square 3) :return-value 9))))) (:title "Function as Object" :bullet-points ((:description ,(with-output-to-string (ss) (html-stream ss ((:table :border 1) (:tr ((:th :width 0.5)) ((:th :width 0.5 ) "Function (Common Lisp)") ((:th :width 0.5 ) "Object (Gendl)")) (:tr (:td (:b "Typical Purpose")) ((:td :bgcolor (lookup-color :aquamarine :format :hex) :colspan 2) (:ol (:li "Accept some " (:i "inputs")) (:li "possibly performs some " (:i "side-effects")) (:li "compute one or more " (:i "outputs"))))) (:tr (:td (:b "How to Use")) ((:td :bgcolor (lookup-color :thistle :format :hex)) "You call it by name, by evaluating a Lisp expression") ((:td :bgcolor (lookup-color :aquamarine :format :hex)) (:ol (:li "You create or retrieve an " (:i "object")) (:li "You send " (:i "messages") " to the object to get the outputs")))) (:tr (:td (:b "How to Define")) ((:td :background "#CCEEFF") (:pre (:b "<span class=lisp-code>defun <i>name</i> <i>argument-list</i> <i>body</i></span>"))) ((:td :background "#CCEEFF") (:code (:pre (:b "<span class=gdl-operator>define-object</span>&nbsp; <span class=gdl-object-def><i>name</i></span> &nbsp; <span class=lisp-code><i>mixin-list</i></span> &nbsp; <span class=lisp-code><i>specifications</i></span>"))))) (:tr (:td (:b "How to Decompose Complexity")) ((:td :background "#CCEEFF") "Call other function definitions from within a function definition") ((:td :background "#CCEEFF") (:ol (:li "<i>Inherit</i> <i>slots</i> from other definitions using <i>mixins</i>") (:li "Include <i>objects</i> of other types inside an object"))))))) :suppress-end-dot? t))) (:title "Basic <span class=gdl-operator style=\"font-size: 1em;\">define-object</span> Syntax" :bullet-points ((:description "(<span class=gdl-operator>define-object</span>&nbsp; <span class=gdl-object-def><i>definition-name</i></span> (<span class=lisp-code><i>mixins</i></span>) <span class=lisp-code><i>specifications</i></span>)") (:description "<span class=gdl-object-def><i>definition-name</i></span> is a symbol, just like a defun name.") (:description "<span class=lisp-code><i>mixins</i></span> are zero or more names of other <span class=gdl-object-def><i>definition-names</i></span> from which this definition will <i>inherit</i> characteristics.") (:description "The body of the object definition consists of the <span class=lisp-code><i>specifications</i></span>, which is a set of keyword/value pairs controlling the computational ``blueprint'' for this object."))) (:title "<span class=gdl-operator style=\"font-size: 1em;\">define-object</span> Syntax, Cont'd: <span class=gdl-section-keyword style=\"font-size: 1em;\"><i>:computed-slots</i></span>" :bullet-points ((:description "<span class=gdl-section-keyword>:computed-slots</span> can represent known values, intermediate results, or the final <i>outputs</i> which can be computed by an object." :examples ((:define-object speed-of-sound))) (:description "Each slot is defined with a list consisting of a <i>name</i> (a symbol specified by you) followed by an <i>expression</i> which can be any valid CL value or expression.") (:description "<span class=gdl-section-keyword>:computed-slots</span> can refer to the return-value of other slots in the same object using the special Gendl operator <span class = \"gdl-operator\">the</span>.") (:description "In OO terminology, <span class=gdl-section-keyword>:computed-slots</span> are one mechanism which provides <i>message-passing</i> behavior.") )) (:title "Making Objects and Sending Messages to Them" :bullet-points ((:description "After a definition is saved, compiled, and loaded into memory, you can make an actual object with the operator <span class=lisp-code>make-object</span> (here, we are setting the object to a toplevel variable named <span class=lisp-code>obj</span>):" :examples ((:code (setq obj (make-object 'speed-of-sound)) :return-value* "<speed-of-sound 26112>"))) (:description "You can then send <i>messages</i> to the object held in the variable <span class=lisp-code>obj</span> with the operator <span class=lisp-code>the-object</span>:" :examples ((:code (the-object obj speed) :return-value 9.5939274091766))) (:description "<i>Note:</i> in normal Gendl usage, most objects are created on-the-fly, on-demand, automatically (as child objects of other objects), so you will not usually be calling <span class=lisp-code>make-object</span> explicitly by yourself, except for testing or batch computations." ))) (:title "<span class=gdl-operator style=\"font-size: 1em;\">define-object</span> Syntax, Cont'd: <span class=gdl-section-keyword style=\"font-size: 1em;\"><i>:input-slots</i></span>" :bullet-points ((:description "The <span class=gdl-section-keyword>:input-slots</span> section is where you put names for values which can or must be \"passed in\" to an object when the object is created.") (:description "<span class=gdl-section-keyword>:input-slots</span> can be <i>required</i> or <i>optional</i> (We will discuss <i>optional</i> ones later).") (:description "<i>Required</i> <span class=gdl-section-keyword>:input-slots</span> are specified with a symbol (not inside its own list):" :examples ((:define-object speed-of-sound-at-temperature))))) (:title "Making an Object and passing in Inputs</i>" :bullet-points ((:description "The values for the <span class=gdl-section-keyword>:input-slots</span> can be passed into <span class=lisp-code>make-object</span> as keyword arguments:" :examples ((:code (setq obj (make-object 'speed-of-sound-at-temperature :temperature 288)) :return-value* "<speed-of-sound-at-temperature 26120>") (:code (the-object obj speed) :return-value 9.853972557948394) (:code (setq obj (make-object 'speed-of-sound-at-temperature :temperature 242)) :return-value* "<speed-of-sound-at-temperature 26343>") (:code (the-object obj speed) :return-value 9.03280817811936) )))) (:title "<i>Exercises</i> 1" :bullet-points ((:description "1. Write an object definition to compute the Lift (force) on an airfoil. Your definition should contain the following <span class=gdl-section-keyword>:input-slots</span>: <dl> <dt><span class=gdl-message-name>rho</span><dd>for the air density <dt><span class=gdl-message-name>v</span><dd>for the velocity <dt><span class=gdl-message-name>A</span><dd>for the surface area <dt><span class=gdl-message-name>C-of-L</span><dd>for the coefficient of lift </dl> and should compute <span class=gdl-message-name>lift-force</span> as a <span class=gdl-section-keyword>:computed-slot</span>.") (:description "Test your definition by making objects with the following sets of values, and sending each one the <span class=gdl-message-name>lift-force</span> message:" :examples ((:code (make-object 'lift-calculator :rho 1.22 :v 108 :A 25 :C-of-L 0.20)) (:code (make-object 'lift-calculator :rho 1.22 :v 123 :A 38 :C-of-L 0.20)) (:code (make-object 'lift-calculator :rho 1.22 :v 142 :A 42 :C-of-L 0.20)))))) (:title "Child <span class=gdl-section-keyword style=\"font-size: 1em;\">:objects</span>" :bullet-points ((:description "The <span class=gdl-section-keyword>:objects</span> section is where you put the names, types, and specify the input values for <i>child</i> objects") (:description "The type is specified with the keyword <span class=lisp-code>:type</span> followed by a literal (i.e. quoted) or computed symbol.") (:description "The rest of the inputs are given as pairs of keyword/expression:" :examples ((:define-object speeds-of-sound))))) (:title "Child objects in a <span class=lisp-code-keyword style=\"font-size: 1em;\">:sequence</span>" :bullet-points ((:description "You can make a sequence by giving the special input keyword <span class=lisp-code>:sequence</span>.") (:description "A standard (simple) sequence then takes a list with <span class=lisp-code>(:size &lt;<i>positive-integer</i>&gt;)</span>.") (:description "Individual child elements can be accessed from within the object specification with the special operator <span class=gdl-operator>the-child</span>.") (:description "You can produce a standard CL list from a sequence with the special Gendl operator <span class=lisp-code>list-elements</code>:" :examples ((:define-object speeds-of-sound-sequence))))) (:title "Referring to an element in a <span class=lisp-code-keyword style=\"font-size: 1em;\">:sequence</span>" :bullet-points ((:description "The sequenced object itself is of a special type called an <i>aggregate</i>") (:description "To fetch an element, you wrap parentheses around the message for the aggregate, and give the index number as an argument" :examples ((:code (setq object (make-object 'speeds-of-sound-sequence)) :return-value "<speeds-of-sound-sequence @ #x74ed72ca>") (:code (the-object object (speeds 0) speed) :return-value 9.03280817811936) (:code (the-object object (speeds 1) speed) :return-value 9.853972557948394) (:code (the-object object (speeds 2) speed) :return-value 10.386999094637488))))) (:title "<i>Exercises</i> 2" :bullet-points ((:description "2. Write an object definition to compute the average lift force given a list of input plists, for example:" :examples ((:code (list (list :rho 1.22 :v 108 :A 25 :C-of-L 0.20) (list :rho 1.22 :v 123 :A 38 :C-of-L 0.20) (list :rho 1.22 :v 142 :A 42 :C-of-L 0.20))))) (:description "The length of the sequence should be driven by the length of the input list.") (:description "You can use some combination of <span class=lisp-code>nth</span>, <span class=lisp-code>getf</span>, and <span class=gdl-operator>the-child</span> to retrieve the correct values for each input in the child sequence") (:description "You might already have the definition for the child objects from the first Exercise."))) (:title "Gendl <span class=gdl-section-keyword style=\"font-size: 1em;\">:functions</span>" :bullet-points ((:description "The <span class=gdl-section-keyword>:functions</span> section is where you put the names, argument lists, and bodies for <i>Functions</i> which can operate within the context of a Gendl object.") (:description "Not to be confused with normal CL functions defined with <span class=lisp-code>defun</span> (although syntax is nearly the same).") (:description "The big difference is that Gendl <span class=gdl-section-keyword>:functions</span> can make use of <span class=lisp-code>the</span> to refer to messages within the same object" :examples ((:define-object speed-of-sound-at-temperature-func))))) (:title "Calling Gendl <span class=gdl-section-keyword style=\"font-size: 1em;\">:functions</span>" :bullet-points ((:description "To refer to the function with <span class=lisp-code>the</span> or <span class=lisp-code>the-object</span>, you wrap its name with parentheses and give the arguments, as with a normal CL function" :examples ((:code (let ((object (make-object 'speed-of-sound-at-temperature-func))) (the-object object (speed 280))) :return-value 9.71614797221615))))) (:title "<i>Exercises</i> 3" :bullet-points ((:description "3. Add a Gendl function to your lift calculating object which accepts <span class=lisp-code>C-of-L</span> as an argument, instead of using the <span class=lisp-code>:input-slot</span> from the definition as it does now.") (:description "Test your definition by making an object from it and calling the function with the following values for coefficient-of-lift: <ol> <li><span class=lisp-code>0.15</span> <li><span class=lisp-code>0.18</span> <li><span class=lisp-code>0.20</span> <li><span class=lisp-code>0.22</span> <li><span class=lisp-code>0.25</span> </ol>") (:description "Compare your results with your neighbor.")))))))
15,761
Common Lisp
.lisp
270
50.962963
174
0.67139
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
38e0049079865865df945ebb4f69a93fd5e868dbe2a5d16e97488ca3a2ee3844
36,182
[ -1 ]
36,183
session-01.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/session-01.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (Gendl). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object introduction (slide-show-leaf) :computed-slots ((strings-for-display "Introduction") (slide-data `((:title "Goals" :bullet-points ((:description "Spark an interest in using a Generative approach for solving Engineering problems") (:description "Qualify you all to Read, Understand, and Develop Gendl applications") (:description "Give you the eyes to see situations where Generative technology and Gendl will be a good fit") )) (:title "Topics Covered in G102" :bullet-points ((:description ,(with-cl-who-string () "Objects in Gendl and the " ((:span :class "gdl-operator") "define-object") " operator" (:ul (:li "Debugging (basic)") (:li "Inspection & Visualization (tasty)")))) (:description ,(with-output-to-string (ss) (html-stream ss "Geometry and Coordinate Systems" (:ul (:li "Points") (:li "Curves") (:li "Surfaces") (:li "Solids"))))) (:description "Custom User Interfaces (optional)") (:description "Interacting with the Outside World") (:description "Debugging and Performance (detailed)"))) (:title "What is Gendl?" :bullet-points ((:description "A Dynamic, Declarative, Object-oriented language environment embedded in Common Lisp") (:description "A technology which allows any type of engineer to define problems and their solutions using an intuitive, straightforward structure") (:description "A cross-platform server solution for web application deployment"))) (:title "A Path of Discovery: Gendl as a Learning Tool" :bullet-points ((:description "Humans learn best through Action and Discovery") (:description "Applies to learning Gendl itself") (:description "Applies to learning about your own engineering domain")))))))
3,275
Common Lisp
.lisp
57
43.54386
135
0.601326
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
616f17c6a26a8d8e0452008302ae6bb2d91256a1bc73a25409ec54c13c19db3c
36,183
[ -1 ]
36,184
user-interface.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/user-interface.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (Gendl). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object user-interface (slide-show-leaf) :computed-slots ((strings-for-display "Human Interfaces") (slide-data `((:title "<span class=gdl-object-def style=\"font-size: 1em;\">base-ajax-sheet</span>" :bullet-points ((:description "Code for a web interface goes in-package <span class=lisp-code>:gwl-user</span>, or define your own with <span class=gdl-operator>gwl:define-package</span>.") (:description "Basic mixin to make a web page: <span class=gdl-object-def>base-ajax-sheet</span>.") (:description "You include a <span class=gdl-message-name>main-sheet-body</span> to compute a string of HTML for your page content.") (:description "<span class=lisp-code>with-cl-who-string</span> is an operator from <a href=http://weitz.de/cl-who/>Edi Weitz</a> used for generating the actual HTML tags and content.") (:description "You <i>publish</i> the object as a web page using <span class=lisp-code>publish-gwl-app</span>" :examples ((:define-object wing-surface-and-volume :include-page-link? t))))) (:title "Separate Sheet Sections and Form Controls" :bullet-points ((:description "Ajax can update just the sheet sections which change") (:description "Form Controls are child objects with <span class=gdl-message-name>default</span> and <span class=gdl-message-name>value</span>") (:description "You include a separate <span class=gdl-object-def>sheet-section</span> for each section which should be able to update as a unit.") (:description "The main-div from each section should be laid out in the main sheet." :examples ((:define-object wing-surface-and-volume-ajax :include-page-link? t))))) (:title "<i>Exercise 10</i>" :bullet-points ((:description "Modify the example from the previous slide to use your two-spar wing from Exercise 9, and add a Form Control for the profile scaling."))) (:title "Including Graphics for Geometric Objects" :bullet-points ((:description "Make a child object of type <span class=gdl-object-def>base-ajax-graphics-sheet</span>") (:description "Basic inputs are <ul> <li><span class=gdl-message-name>:display-list-objects</span> <li><span class=gdl-message-name>:display-list-object-roots</span> <li><span class=gdl-message-name>:view-direction-default</span> <li><span class=gdl-message-name>:length</span> <li><span class=gdl-message-name>:width</span> </ul>") (:description "The main-div for the viewport should be laid out in the main sheet." :examples ((:define-object wing-with-graphics :include-page-link? t))))) (:title "<i>Exercise 11</i>" :bullet-points ((:description "Modify the example from the previous slide to include graphics for your two-spar wing from Exercise 9, and an input for the profile scaling."))) (:title "Linking to other Sheets" :bullet-points ((:description "The <span class=gdl-message-name>url</span> message will produce a link to the page:" :examples ((:define-object several-wings :include-page-link? t))))) (:title "Calling Gendl Functions and Setting Slot Values" :bullet-points ((:description "the <span class=gdl-message-name>gdl-ajax-call</span> Gendl function will generate a Javascript function call which can invoke a Gendl function:" :examples ((:define-object wing-with-restore))) (:description "With <span class=gdl-message-name>gdl-ajax-call</span> you can also include a list of form-controls whose values should be set (\"bashed\") into the model:" :examples ((:define-object wing-with-submit))))) (:title "<i>Exercise 12</i>" :bullet-points ((:description "Modify the <span class=gdl-object-def>several-wings</span> example to have a button which restores the defaults on the spans of all the child wing models."))) ))))
5,222
Common Lisp
.lisp
119
36.773109
91
0.676932
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4b57a4a8bcd2923e1b80d6041eb6c5dd446141f21833c14b921710a807321a23
36,184
[ -1 ]
36,185
session-05.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/session-05.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object session-05 (slide-show-leaf) :computed-slots ((slide-data `((:title "Points" :bullet-points ((:description "<i>Points</i> represent Cartesian Coordinates in 3-dimensional space") (:description "A <i>Point</i> in GDL is represented as an Object of type <i>3D-point</i>") (:description "Because points are used so frequently, they have their own instantiation function, <i>make-point</i>:" :examples ((:code (make-point 0 0 0) :return-value "#(0.0 0.0 0.0)") (:code (make-point 10 20 30) :return-value "#(10.0 20.0 30.0)"))) (:description "The coordinates in a <i>3D-point</i> are just numbers -- they have no inherent dimensions"))) (:title "Points, Cont'd" :bullet-points ((:description "The <i>3D-point</i> object supports the following <i>accessor functions</i>:" :examples ((:code (get-x (make-point 10 20 30)) :return-value 10.0) (:code (get-y (make-point 10 20 30)) :return-value 20.0) (:code (get-z (make-point 10 20 30)) :return-value 30.0))) (:description "And you can get the 3-dimensional distance between two <i>3D-points</i> with the function <i>3D-distance</i>:" :examples ((:code (3d-distance (make-point 0 0 0) (make-point 10 20 30)) :return-value 37.416573867739416))))) (:title "Vectors" :bullet-points ((:description "A <i>Vector</i> represents a <i>direction</i> and <i>magnitude</i> in 3-dimensional space") (:description "A Vector in GDL is represented as an Object of type <i>Precise-float-vector</i>") (:description "Because <i>Vectors</i> are used so frequently, they have their own instantiation function, <i>make-vector</i>:" :examples ((:code (make-vector 0 0 0) :return-value #(0.0 0.0 0.0)) (:code (make-vector 10 20 30) :return-value #(10.0 20.0 30.0)))) (:description "The coordinates in a <i>Vector</i> are just numbers -- they have no inherent dimensions"))) (:title "Vectors vs. Points" :bullet-points ((:description "Technically, <i>3D-points</i> and <i>Vectors</i> are implemented the same way, thus they are interchangeable") (:description "However, <i>semantically</i> you can think of a <i>Vector</i> as an ``arrow-line'' in space with its tail at the Origin (i.e. #(0.0 0.0 0.0)) and its head at the point represented in the vector") (:description "Remember, a <i>Vector</i> has only <i>direction</i> and <i>magnitude</i>, so although it has its tail nominally at the Origin, it can be considered as being <i>anywhere</i> in 3-dimensional space, as long as it maintains the same <i>direction</i> and <i>magnitude</i>"))) (:title "Manipulating Vectors" :bullet-points ((:description "Vectors support standard <i>vector arithmetic</i>, including <i>add-vectors</i> and <i>subtract-vectors</i>:" :examples ((:code (add-vectors (make-vector 0 0 1) (make-vector 0 1 0)) :return-value #(0.0 1.0 1.0)) (:code (subtract-vectors (make-vector 0 1 1) (make-vector 0 1 0)) :return-value #(0.0 0.0 1.0)))))) (:title "Creating Vectors from Points" :bullet-points ((:description "Often, it is useful to obtain a vector which points in the direction from one point to another" :description "For this purpose, we can exploit the fact that Vectors and Points are interchangeable:" :examples ((:define-object point-demo))))) (:title "Translating Points" :bullet-points ((:description "The function <i>Translate-along-vector</i> is commonly used to compute a <i>3D-point</i> which is the result of translating a ``start point'' along a certain <i>Vector</i> by a specified <i>distance</i>:") (:description "<i>Translate-along-vector point vector distance</i>" :examples ((:define-object translation-demo))))) (:title "Using Points to specify a Child Part's Center" :bullet-points ((:description "You can pass the special input <i>:center</i> into a child part to specify where its center (and thus, the entire part) should be positioned:" :examples ( (:define-object city-4)))))))) :functions ((strings-for-display nil "Points and Vectors")))
4,901
Common Lisp
.lisp
96
48.583333
104
0.713988
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2e12eb87ef81d776cf6651d2737566ae24f0c236cc4b7847fa6726cac37b5111
36,185
[ -1 ]
36,186
session-06.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/session-06.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object session-06 (slide-show-leaf) :computed-slots ((slide-data '((:title "Exercises" :bullet-points ((:description "Complete the provided <i>city</i> object to accept a list of <i>zoning ordinances</i> which contain <i>proximity rules</i>, as in the skeleton code." ) (:description "Skeleton code is provided for download") (:description "<i>Extra Credit</i>:<br> Plot a large <b>:red</b> sphere at the center of each violating neighbor") (:description "<i>Extra Credit 3</i>:<br> Prepare a textual report listing the coordinates of the offending buildings and other details of the violated rule.")))))) :functions ((strings-for-display nil "Exercise with Proximity Rules")))
1,624
Common Lisp
.lisp
37
41.351351
79
0.743312
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
497f2851d3596ef1fcbb06bb43e78e0abbce4f3e31faaf79754e6a4da56a61e5
36,186
[ -1 ]
36,187
tower-example.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/tower-example.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object tower-example (slide-show-leaf) :computed-slots ((slide-data `( (:title "Single Box" :bullet-points ((:description "Start with a single box:" :examples ((:define-object tower-box))) (:description ,(string-append "In ta2 with a trimetric view: " (with-cl-who-string () ((:img :src "/g102/images/single-box.png"))))) )) (:title "Sequence of Boxes" :bullet-points ((:description "Now make 25 of them:" :examples ((:define-object tower-boxes))) (:description ,(string-append "In ta2 with a trimetric view: " (with-cl-who-string () ((:img :src "/g102/images/tower-boxes.png"))))) )) (:title "Stack of Boxes" :bullet-points ((:description "Now stack them on top of each other:" :examples ((:define-object stacked-boxes))) (:description ,(string-append "In ta2 with a trimetric view: " (with-cl-who-string () ((:img :src "/g102/images/stacked-boxes.png"))))) )) (:title "Twisted Stack" :bullet-points ((:description "Now apply a uniform twist, about the global top (Z) axis, to each one:" :examples ((:define-object twisted-stacked-boxes))) (:description ,(string-append "In ta2 with a trimetric view: " (with-cl-who-string () ((:img :src "/g102/images/twisted-stacked-boxes-trimetric.png"))))) (:description ,(string-append "In ta2 with a top view: " (with-cl-who-string () ((:img :src "/g102/images/twisted-stacked-boxes-top.png"))))))) ))) :functions ((strings-for-display nil "Tower Example")))
2,676
Common Lisp
.lisp
73
30.342466
74
0.665718
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
db4bdc3d945716c56dd0164522447d1fac529daebdb2a1eea3fa124de832c466
36,187
[ -1 ]
36,188
session-04.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/session-04.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object session-04 (slide-show-leaf) :computed-slots ((slide-data `((:title "Objects" :bullet-points ((:description "Child instances") (:description "Roughly analogous to calls of one defun from within another Defun") (:description "Break complicated computation into smaller pieces and ``distribute'' complexity" :examples ((:define-object city))))) (:title "Passing <i>:inputs</i> to a child object using a plist" :bullet-points ((:description "Except for its <i>:Type</i>, all inputs to a child can be passed in using a plist and the special keyword <i>:Parameters</i> (assuming you have available a plist of the child's parameters). <p> Note: <i>The </i>:Type<i> should always be specified explicitly (although it will default to the child object's name if not given)</i>" :examples ((:define-object city-2))))) (:title "Sequences of Objects" :bullet-points ((:description "You can specify an <i>Array</i> of child object using <i>:sequence quantification</i>") (:description "Example" :examples ((:define-object city-3))))) ))) :functions ((strings-for-display nil "Child Objects")))
2,085
Common Lisp
.lisp
50
38.56
88
0.725558
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d13ceb8700af2f4c36ea731de2b3cc9cb5499bb5176a539eb73c6bfa1e95edf5
36,188
[ -1 ]
36,189
session-07.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/session-07.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object session-07 (slide-show-leaf) :computed-slots ((slide-data `( (:title "Face-normal vectors" :bullet-points ((:description "A box or any derivative thereof will answer the message <b>:face-normal-vector</b>.") (:description "The <b>:face-normal-vector</b> message takes an argument of one of the following keywords: <ul> <b> <li>:front</li> <li>:rear</li> <li>:left</li> <li>:right</li> <li>:top</li> <li>:bottom</li> </b> </li>") (:description "Since the <b>:face-normal-vector</b> takes an argument, you have to wrap it with parenthesis like a function call:" :examples ((:code (the (face-normal-vector :top))))) (:description "Normally, <b>:right</b>, <b>:rear</b>, and <b>:top</b> correspond to the X, Y, and Z axes"))) (:title "Orientation" :bullet-points ((:description "You can redefine an object's idea of <b>:right</b>, <b>:rear</b>, <b>:top</b>, etc, by defining the <b>orientation</b> slot within the object's definition:" :examples ((:define-object self-aligning-box))) (:description "<b>:orientation</b> requires a transformation matrix, which is generally computed by calling the function <i>alignment</i> with the appropriate keyword arguments") (:description "Note that aligning two (2) axes of a part is sufficient to define its orientation, since the third axis will always be the <i>cross-vectors</i> of the first two"))) (:title "Exercises" :bullet-points ((:description "Exercise -- find intersection for Ackermann Assembly") (:description "Skeleton code is available for download")))))) :functions ((strings-for-display nil "Orientation")))
2,624
Common Lisp
.lisp
66
36.227273
88
0.702245
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
1e1b3cd6fddddd463f8b018a77b263a46604a4104b147b5d6849b124b5d9f233
36,189
[ -1 ]
36,190
session-03.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/session-03.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) #| (sqrt (* gamma R T)) (half (* rho (* V V) S C-of-lift)) |# (define-object session-03 (slide-show-leaf) :computed-slots ((strings-for-display "Functional vs Declarative Style") (slide-data `((:title "Functional Style" :bullet-points ((:description "Programs Work by Returning Values, instead of Modifying Things") (:description "Dominant paradigm in Lisp") (:description "Allows Interactive Testing") (:description "Test each Function as you Write it") (:description "Instant feedback and confidence make a huge difference in the aggregate"))) (:title "Declarative, Functional Style" :bullet-points ((:description "Brings Functional Style to an even higher level") (:description "Dominant paradigm in GDL") (:description "Allows Dynamic, Interactive, Order-independent Testing") (:description "Test each ``rule'' (attribute) as you write it") (:description "Continuous feedback loop makes huge difference in the aggregate"))) (:title "Procedural vs. Declarative Computation" :bullet-points ((:description "Many computational problems require that we compute several <i>intermediate results</i> before we can arrive at our <i>final output</i>") (:description "In Procedural Programming, we have basically two choices for doing this: <ol> <li>Sequentially set variables to our intermediate results, then use these variables to compute our final result</li> <li>Compute all intermediate results using ``nested'' function calls</li>"))) (:title "Procedural vs. Declarative Computation, Cont'd: <i>Let</i> and <i>Let*</i>" :bullet-points ((:description "Note that in Lisp, <i>Let</i> assigns variables in <i>parallel</i> (i.e. logically, they all get set simultaneously), so the value one <i>let</i> variable cannot depend on the value of another" :examples ((:code (let ((a 3) (b (twice a))) b) :return-value "Error: Attempt to take the value of the unbound variable `A'"))) (:description "Common Lisp does define <i>Let*</i> for the purpose of sequentially assigning variables" :examples ((:code (let* ((a 3) (b (twice a))) b) :return-value 6))) (:description "However, the use of <i>let*</i> is discouraged by Lisp purists because it smacks of side-effecting and introduces a lot of order-dependency") (:description "<i>Let*</i> forms actually get macro-expanded into nested <i>Let</i>'s:" :examples ((:code (let ((a 3)) (let ((b (twice a))) b)) :return-value 6))) (:description "So from this perspective, you can see that, under the hood, <i>let*</i>'s can get messy pretty fast!") (:description "As we will see in a moment, a Defun with a long <i>let*</I> is a good indication that you would probably be better off using an object in that case!" :suppress-end-dot? t))) (:title "<i>Let*, Cont'd</i>" :bullet-points ((:description "Assume we need a function to take a number, double it, add 1000 to it, then, if the result is greater than 5000, add 5% to it, then divide that result by 24" :examples ((:code (defun hairy-calc (num) (let* ((a (twice num)) (b (+ a 1000)) (c (if (> b 5000) (+ b (* b 0.05)) b)) (d (/ c 24))) d)) :return-value hairy-calc) (:code (hairy-calc 50) :return-value 275/6))) (:description "You have to pay close attention to the order in which you assign the <i>let*</i> variables") (:description "This program would be difficult to debug if there were an error or typo in any one of the <i>Let*</i> assignments."))) (:title "Nested Function Calls" :bullet-points ((:description "Here is <i>hairy-calc</i> using nested function calls" :examples ((:code (defun hairy-calc (num) (/ (if (> (+ (twice num) 1000) 5000) (+ (+ (twice num) 1000) (* (+ (twice num) 1000) 0.05)) (+ (twice num) 1000)) 24)) :return-value hairy-calc) (:code (hairy-calc 50) :return-value 275/6))) (:description "Already it is difficult to read, contains a lot of repeated code, and would be unpleasant to debug. As programs grow in complexity this problem grows even faster."))) (:title "Declarative Style" :bullet-points ((:description "Using a Object, we can express the solution in <i>declarative style</i>" :examples ((:define-object hairy-calc) (:code (defun hairy-calc (num) (the-object (make-part 'hairy-calc :num num) :d)) :return-value hairy-calc) (:code (hairy-calc 50) :return-value 275/6))) (:description "We can specify the attributes in any order. The only requirement is that we have no <i>circular references</i> (more on this later)" :examples ((:define-object hairy-calc)))))))))
6,777
Common Lisp
.lisp
105
49.238095
135
0.58035
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
342de0c9a5d8e1f5da5803ccfd4392d38fd734028878ddb973a1a7415c2201ff
36,190
[ -1 ]
36,191
geometry.lisp
lisp-mirror_gendl/documentation/training/g102/slides/source/geometry.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (Gendl). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102) (define-object geometry (slide-show-leaf) :computed-slots ((strings-for-display "Geometry") (slide-data `((:title "<span class=gdl-object-def style=\"font-size: 1em;\"> base-object</span>" :bullet-points ((:description "You can mix in <span class=gdl-object-def>base-object</span> to get a basic coordinate system.") (:description "This includes input messages for <span class=gdl-message-name>length</span>, <span class=gdl-message-name>width</span>, <span class=gdl-message-name>height</span>, <span class=gdl-message-name>center</span>, and <span class=gdl-message-name>orientation</span>, and Gendl functions for each <span class=gdl-message-name>vertex</span>, <span class=gdl-message-name>face-center</span>, <span class=gdl-message-name>edge-center</span>, and <span class=gdl-message-name>face-normal-vector</span>."))) (:title "<span class=gdl-object-def style=\"font-size: 1em;\">box</span>" :bullet-points ((:description "All Gendl geometry primitives mix in (inherit from) <span class=gdl-object-def>base-object</span>. Perhaps the simplest geometry primitive is <span class=gdl-object-def>box</span>:" :examples ((:define-object single-box :include-sample-drawing? nil ;;t ))) (:description "Typically, your the actual geometry will end up in leaf-level child objects, while higher-level nodes might be simple <span class=gdl-object-def>base-object</span>s."))) (:title "<span class=gdl-section-keyword style=\"font-size: 1em;\"> trickle-down-slots</span>" :bullet-points ((:description "<span class=gdl-message-name>length</span>, <span class=gdl-message-name>width</span>, <span class=gdl-message-name>height</span>, <span class=gdl-message-name>center</span>, and <span class=gdl-message-name>orientation</span> are actually defined as <span class=gdl-section-keyword>:trickle-down-slots</span> in <span class=gdl-object-def>base-object</span>, which means that you do not have to pass these down (they \"trickle down\" automatically). So the previous example is equivalent to:" :examples ((:define-object single-box-trickle))) (:description "If you are ever tempted to define your own <span class=gdl-section-keyword>:trickle-down-slots</span> in your definitions, do it with caution; they can make it difficult to trace where values are coming from."))) (:title "Working with points and vectors" :bullet-points ( (:description "3D points are represented in Gendl as a <i>vector</i> of three numbers") (:description "You can make a point from three numbers with the <span class=gdl-operator>make-point</span> operator:" :examples ((:code (make-point 0 0 0) :return-value #(0.0 0.0 0.0)) (:code (make-point 10 20 30) :return-value #(10.0 20.0 30.0)))) (:description "Or by translating another point along a vector with <span class=gdl-operator>translate-along-vector</span> operator:" :examples ((:code (translate-along-vector (make-point 0 0 0) (make-vector 0 0 1) 10) :return-value #(0.0 0.0 10.0)) (:code (translate-along-vector (make-point 0 0 0) (make-vector 1 1 1) 1) :return-value #(0.5773502691896258 0.5773502691896258 0.5773502691896258)))) (:description "Other operators for manipulating points and vectors include <span class=gdl-operator>rotate-point</span>, <span class=gdl-operator>rotate-point-d</span>, <span class=gdl-operator>rotate-vector</span>, <span class=gdl-operator>rotate-vector-d</span>, <span class=gdl-operator>subtract-vectors</span>, <span class=gdl-operator>add-vectors</span>, and <span class=gdl-operator>scalar*vector</span>") (:description "See the Documentation tab in Tasty for full reference on these operators"))) (:title "Positioning a child object with <span class=gdl-message-name style=\"font-size: 1em;\">center</span>" :bullet-points ((:description "Objects can be positioned by specifying their <span class=gdl-message-name>center</span>, which is expected to be a <i>3D point</i>.") (:description "Within the context of an object definition, you can simply use the <span class=gdl-operator>translate</span> operator to translate a point by a distance in any of the six direction keywords: <span class=lisp-code>:right</span>, <span class=lisp-code>:left</span>, <span class=lisp-code>:rear</span>, <span class=lisp-code>:front</span>, <span class=lisp-code>:top</span>, and <span class=lisp-code>:down</span>") (:description "<span class=lisp-code>:right</span> is the X axis, <span class=lisp-code>:rear</span> is the Y axis, and <span class=lisp-code>:top</span> is the Z axis:" :examples ((:define-object five-boxes :include-sample-drawing? ;;nil t ))))) (:title "Orienting a child object with <span class=gdl-message-name style=\"font-size: 1em;\">orientation</span>" :bullet-points ((:description "You can use the <span class=gdl-operator>alignment</span> operator to produce a 3x3 orthonormal transformation matrix suitable for use as an <span class=gdl-message-name>orientation</span>.") (:description "Alignment takes up to three direction keywords (the third is only necessary if you want to force a left-handed coordinate system):" :examples ((:define-object tilted-monolith :include-sample-drawing? ;; nil t ))))) (:title "<i>Exercises</i> 4 and 5" :bullet-points ((:description "4. Make a twisty tower of boxes, resembling the image below:" :image-url "tower-ex.png") (:description "5. Make a traditional brick wall, with alternating rows shifted by 1/2 brick width, and flush sides (you need half-width bricks on the ends in alternate rows)."))) (:title "Other Wireframe Objects" :bullet-points ((:description "Many mechanical and layout applications do not require surfaces and solids") (:description "Built-in wireframe objects are in the <span class=lisp-code>:geom-base</span> package") (:description "Wireframe primitives do not support generic intersections, mass properties, parametric evaluation") (:description "Common wireframe primitives:" :examples ((:define-object cylinder-sample :include-sample-drawing? ;;nil t ) (:define-object cone-sample :include-sample-drawing? ;; nil t ) (:define-object sphere-sample :include-sample-drawing? ;; nil t ) (:define-object spherical-cap-sample :include-sample-drawing? ;; nil t ) (:define-object torus-sample :include-sample-drawing? ;; nil t ) (:define-object global-filleted-polygon-projection-sample :include-sample-drawing? ;; nil t ))) (:description "See full documentation for these in <a href=http://localhost:9000/yadd>YADD</a> (also available as <i>Documentation</i> tab in tasty)"))) #+nil (:title "Curves, Surfaces, and Solids" :bullet-points ((:description ":surf package supports NURBS curves and surfaces") (:description "If you can understand Curves then you can understand Surfaces") (:description "The NURBS Book (Piegl, Tiller) is the definitive reference") (:description "<b>N</b>on-<b>U</b>niform <b>R</b>ational <b>B</b>-<b>S</b>plines") (:description "<b>Non-Uniform</b> means a curve (or surface) can have a knot vector (or knot grid) which induces non-uniform parameterization.") (:description "<b>Rational</b> means a curve or surface can have weighting factors (one per control point) to affect the geometry. Weights are required to represent analytics (e.g. arcs (spheres)) using NURBS.") (:description "<b>B-Splines</b> \"B\" from \"Bezier\" (I think), and it means the curve (surface) is controlled by a list (grid) of 3D control-points.") (:description "Sometimes the control-points are combined with the weights and written as 4D points."))) #+nil (:title "Curve data structure in Gendl" :bullet-points ((:description "NURBS curves data structure contains four pieces of data: <ol> <li><span class=gdl-message-name>control-points</span> (list of 3D points)</li> <li><span class=gdl-message-name>weights</span> (list of numbers, one per control point)</li> <li><span class=gdl-message-name>degree</span> (a single integer, degree of polynomial curve function)</li> <li><span class=gdl-message-name>knot-vector</span> (list of numbers representing parameter values, affect the shape of the curve)</li> </ol>"))) #+nil (:title "<span class=gdl-object-def style=\"font-size: 1em;\">b-spline-curve</span>" :bullet-points ((:description "defines a NURBS curve which accepts the four components of curve data directly" :examples ((:define-object simple-curve :include-sample-drawing? t))) (:description "Note that with default degree (3) and default weights and knot vector, this is a Cubic Bezier curve and interpolates (i.e. touches) its end points."))) #+nil (:title "Probing the curve object" :bullet-points ((:description "Basic NURBS curve input components" :examples ((:code (make-self 'simple-curve) :return-value "#<simple-curve @ #x740cbf22>") (:code (the curve control-points) :return-value (#(-2.0 0.0 0.0) #(-1.0 1.0 0.0) #(1.0 1.0 0.0) #(2.0 0.0 0.0))) (:code (the curve knot-vector) :return-value (0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0)) (:code (the curve weights) :return-value (1.0 1.0 1.0 1.0)) (:code (the curve degree) :return-value 3))) (:description "Pulling info from the curve" :examples ((:code (the curve total-length) :return-value 4.381037353487265) (:code (the curve u-min) :return-value 0.0) (:code (the curve u-max) :return-value 1.0) (:code (the curve (tangent 0.5)) :return-value #(1.0 0.0 0.0)) (:code (the curve (radius-of-curvature 0.5)) :return-value 3.375))))) #+nil (:title "<i>Exercise</i> 6" :bullet-points ((:description "Change the <span class=gdl-object-def>simple-curve</span> definition from Slide 3.11 to contain a sequence of four (4) child curves. Each child should receive a <span class=lisp-code>:degree</span> passed in which is one greater than its index number (i.e. the degree will start with 1 and work up to 4). Then use an instance of this definition to answer the following questions: <ol type = \"a\"> <li>Is it even possible to produce a curve with the given control points and with each of the specified degree values? <li>Ask each child for its <span class=gdl-message-name>total-length</span>. <li>Does the total-length increase or decrease with an increasing degree? </ol>"))) #+nil (:title "Surface data structure in Gendl" :bullet-points ((:description "NURBS surface data structure contains six pieces of data: <ol> <li><span class=gdl-message-name>control-points</span> --- list of lists of 3D points</li> <li><span class=gdl-message-name>weights</span> --- list of lists of numbers, one per control point</li> <li><span class=gdl-message-name>u-degree</span> --- a single integer, degree of polynomial curve function in u direction</li> <li><span class=gdl-message-name>v-degree</span> --- a single integer, degree of polynomial curve function in v direction</li> <li><span class=gdl-message-name>u-knot-vector</span> --- list of numbers representing parameter values in u direction, affect the shape of the surface in u direction</li> <li><span class=gdl-message-name>v-knot-vector</span> --- list of numbers representing parameter values in v direction, affect the shape of the surface in v direction</li> </ol>"))) #+nil (:title "<span class=gdl-object-def>b-spline-surface</span>" :bullet-points ((:description "defines a NURBS surface which accepts the six components of surface data directly" :examples ((:define-object simple-surface :include-sample-drawing? t))) (:description "Note that with default degree (3) and default weights and knot vector, this is a Cubic Bezier surface and interpolates (i.e. touches) its control points at its corners."))) #+nil (:title "Probing the surface object" :bullet-points ((:description "Basic NURBS surface input components" :examples ((:code (make-self 'simple-surface) :return-value "#<simple-surface @ #x740cbf22>") (:code (the surface control-points) :return-value ((#(-2.0 0.0 -2.0) #(-1.0 1.0 -2.0) #(1.0 1.0 -2.0) #(2.0 0.0 -2.0)) (#(-2.0 0.0 -1.0) #(-1.0 2.0 -1.0) #(1.0 2.0 -1.0) #(2.0 0.0 -1.0)) (#(-2.0 0.0 1.0) #(-1.0 2.0 1.0) #(1.0 2.0 1.0) #(2.0 0.0 1.0)) (#(-2.0 0.0 2.0) #(-1.0 1.0 2.0) #(1.0 1.0 2.0) #(2.0 0.0 2.0)))) (:code (the surface u-knot-vector) :return-value (0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0)) (:code (the surface v-knot-vector) :return-value (0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0)) (:code (the surface weights) :return-value ((1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0))) (:code (the surface u-degree) :return-value 3) (:code (the surface v-degree) :return-value 3))))) #+nil (:title "Probing the surface object (cont'd)" :bullet-points ((:description "Pulling info from the surface" :examples ((:code (the surface area) :return-value 19.745028077271574) (:code (the surface u-min) :return-value 0.0) (:code (the surface u-max) :return-value 1.0) (:code (the surface v-min) :return-value 0.0) (:code (the surface v-max) :return-value 1.0) (:code (the surface (normal 0.5 0.5)) :return-value #(0.0 -1.0 0.0)) (:code (the surface u-iso-curves first) :return-value "#<curve @ #x74d5050a>"))))) #+nil (:title "<i>Exercise</i> 7" :bullet-points ((:description "Change the <span class=gdl-object-def>simple-surface</span> definition from Slide 3.15 to contain a sequence of four (4) child surfaces Each child should receive a <span class=gdl-message-name>:u-degree</span> passed in which is one greater than its index number (i.e. the <span class=gdl-message-name>u-degree</span> will start with 1 and work up to 4). Then use an instance of this definition to answer the following questions: <ol type = \"a\"> <li>Is it even possible to produce a surface with the given control points and with each of the specified <span class=gdl-message-name>u-degree</span> values? <li>Ask each child for its <span class=gdl-message-name>area</span>. <li>Does the area increase or decrease with an increasing <span class=gdl-message-name>u-degree</span>?</ol>"))) #+nil (:title "Transforming Curves and Surfaces" :bullet-points ((:description "Pure curves, surfaces and solids get their position, shape, and dimensions directly from global control points") (:description "They <i>do not</i> respect the reference-box from <span class=gdl-object-def>base-object</span>.") (:description "For transforming curves and surfaces, you can use <span class=gdl-object-def>boxed-curve</span> and <span class=gdl-object-def>boxed-surface</span>.") (:description "Example translated, rotated, and mirrored:" :examples ((:define-object boxed-curves-example :include-sample-drawing? t :projection-direction :top ))))) #+nil (:title "<i>Exercise</i> 8" :bullet-points ((:description "Use the <span class=gdl-message-name>wavy</span> object from the previous example for this exercise. <ol type=\"a\"> <li>Check the reference documentation for <span class=gdl-object-def>boxed-curve</span> and see how to add a scale in X, Y, and Z axes.</li> <li>Add a sequence of three (3) <span class=gdl-object-def>boxed-curve</span>s to the <span class=gdl-object-def>boxed-curves-example</span> and scale them by a factor of 2 in the X, Y, and Z axes, respectively. </li> <li>How does the scaling in each direction affect the <span class=gdl-message-name>total-length</span>?</li> </ol> "))) #+nil (:title "Solids and Booleans" :bullet-points ((:description "Solids are one or more regions bounded by trimmed surfaces (faces).") (:description "Connected faces form a shell.") (:description "A closed shell forms a region.") (:description "A <i>brep</i> can have zero or more shells and one or more regions") (:description "There is always the <i>infinite</i> region (all of space outside the brep)."))) #+nil (:title "Boolean operations" :bullet-points ((:description "Brep operations are <i>closed</i> - breps in, and you always get one or more breps out") (:description "United-solids example" :examples ((:define-object box-cone-unite :include-sample-drawing? t :side-by-side "united.png"))) (:description "Subtracted-solids example" :examples ((:define-object box-cone-subtract :include-sample-drawing? t :side-by-side "subtract.png"))) (:description "Intersected-solids example" :examples ((:define-object box-cone-intersect :include-sample-drawing? t ))))) #+nil (:title "Non-manifold Breps" :bullet-points ((:description "In <i>manifold</i> Breps, all edges are shared by exactly two faces") (:description "Gendl can handle <i>non-manifold</i> Breps, which can be useful as construction geometry") (:description "The <i>merge</i> operation can join together surfaces and faces into a solid, and get rid of extra pieces of faces, in one operation." :examples ((:define-object airfoil :include-sample-drawing? t) (:define-object merged-airfoil :include-sample-drawing? t ) (:define-object regioned-airfoil :include-sample-drawing? t))) (:description "Note that breps only display their edges by default. You can set <span class=lisp-code>*brep-isos-default*</span> to adjust this:" :examples ((:code *brep-isos-default* :return-value nil) (:code (setq *brep-isos-default* (list :n-u 8 :n-v 8)) :return-value (:n-u 8 :n-v 8)))))) #+nil (:title "<i>Exercise 9</i>" :bullet-points ((:description "Add a second spar two-thirds (2/3) of the way from trailing edge to leading edge, and move the first spar to one-third (1/3) of the way. Your <span class=gdl-object-def>regioned-solid</span> should now have three regions instead of two.") (:description "Check that the total <span class=gdl-message-name>volume</span> of the three regions equals the total of the two regions with the single spar.") (:description "Scale the profiles with 10% decreasing chord length as they go from root to tip.") (:description "Re-orient the spars so they follow the leading edge and trailing edge, respectively.") (:description "Make a <span class=gdl-section-keyword>computed-slot</span> which holds the interior (i.e. middle) region (call this the \"fuel tank\"). Add a slot which computes its volume.")))))))
23,100
Common Lisp
.lisp
498
36.24498
140
0.612615
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4d279f22fb5c24a3dfa142c8a44e913152a5e4e2d96d8365bea3cd20a3f56a85
36,191
[ -1 ]
36,192
exercise-6.lisp
lisp-mirror_gendl/documentation/training/g102/solutions/exercise-6.lisp
(in-package :gdl-user) (define-object simple-curve (base-object) :input-slots ((control-points (list (make-point -2 0 0) (make-point -1 1 0) (make-point 1 1 0) (make-point 2 0 0)))) :objects ((curves :sequence (:size 3) :type 'b-spline-curve :degree (1+ (the-child index)) :control-points (the control-points)) (points :type 'points-display :points (the control-points))))
490
Common Lisp
.lisp
16
22.3125
46
0.554371
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
92c1a073ae53a1c11693b1f2df2f1784cb5bd780f2765f7b3e0919963ee67636
36,192
[ -1 ]
36,193
exercise-7.lisp
lisp-mirror_gendl/documentation/training/g102/solutions/exercise-7.lisp
(in-package :gdl-user) (define-object simple-surface (base-object) :input-slots ((control-points (list (list (make-point -2 0 -2) (make-point -1 1 -2) (make-point 1 1 -2) (make-point 2 0 -2)) (list (make-point -2 0 -1) (make-point -1 2 -1) (make-point 1 2 -1) (make-point 2 0 -1)) (list (make-point -2 0 1) (make-point -1 2 1) (make-point 1 2 1) (make-point 2 0 1)) (list (make-point -2 0 2) (make-point -1 1 2) (make-point 1 1 2) (make-point 2 0 2))))) :objects ((surfaces :type 'b-spline-surface :sequence (:size 3) :u-degree (1+ (the-child index)) :display-controls (list :color :blue :line-thickness 2 :bezier-points t) :control-points (the control-points))))
850
Common Lisp
.lisp
21
30.619048
57
0.527778
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e1f7c7a3a0966c5e72d257bd245a78a900b58ad4d9ff5b76c24c4768ce4bbc90
36,193
[ -1 ]
36,194
brick-wall.lisp
lisp-mirror_gendl/documentation/training/g102/solutions/brick-wall.lisp
(in-package :gdl-user) (define-object brick-wall (base-object) :input-slots ((width 250) (height 100) (length (the brick-length)) (spacing (* (the brick-height) 0.07))) :computed-slots ((bricks-in-row (floor (/ (the width) (the brick-width)))) (number-of-rows (floor (/ (the height) (the brick-height)))) (brick-width (the sample-brick width)) (brick-height (the sample-brick height)) (brick-length (the sample-brick length)) (corner (translate (the center) :down (half (the height)) :left (half (the width)))) (extra-even-space (/ (the spacing) (1- (the bricks-in-row))))) :objects ((sample-brick :type 'brick :hidden? t) (rows :type 'brick-row :sequence (:size (the number-of-rows)) :number-of-bricks (the bricks-in-row) :pass-down (brick-width brick-height corner spacing extra-even-space) :height (the brick-height) :width (the width) :center (translate (if (the-child first?) (the corner) (the-child previous center)) :up (if (the-child first?) (half (the-child height)) (+ (the-child height) (the spacing))))))) (define-object brick-row (base-object) :input-slots (number-of-bricks brick-width brick-height corner spacing extra-even-space) :computed-slots ((odd-row? (and (the index) (oddp (the index))))) :objects ((bricks :type 'brick :display-controls (list :color (if (the odd-row?) :red :blue)) :sequence (:size (if (the odd-row?) (1+ (the number-of-bricks)) (the number-of-bricks))) :center (translate (if (the-child first?) (the center) (the-child previous center)) :right (if (the-child first?) (half (the-child width)) (+ (half (the-child previous width)) (half (the-child width)) (if (the odd-row?) (the spacing) (+ (the spacing) (the extra-even-space)))))) :width (if (and (the odd-row?) (or (the-child first?) (the-child last?))) (half (the brick-width)) (the brick-width))))) (define-object brick (box) :input-slots ((length 10) (width 20) (height 15) (display-controls (list :color :blue)))) (define-object brick-wall-display (gwl:base-ajax-graphics-sheet) :computed-slots ((use-x3dom? t) (use-jquery? t) (main-sheet-body (gwl:with-cl-who-string (:indent t) (:p (:h1 "Sample Display of a Brick Wall")) (:p ((:|X3D| :id "brick_sample" :|width| 500 :|height| 500) (:Scene (with-format (x3d *stream*) (write-the wall-drawing cad-output)))))))) :objects ((wall-drawing :type 'gwl:web-drawing :object-roots (list (the wall))) (wall :type 'brick-wall))) (gwl:publish-gwl-app "/brick-wall-display" 'wall-display)
2,693
Common Lisp
.lisp
65
36.323077
92
0.645448
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
60453aea0eec7e94521679b18e701de962e71a7e68dc281de61095749ebd6dc3
36,194
[ -1 ]
36,195
assembly.lisp
lisp-mirror_gendl/documentation/training/g102/solutions/city/source/assembly.lisp
(in-package :city) (define-object assembly (application-mixin) :input-slots ((height 10) (width 2000 :settable) (length 1000 :settable) (number-of-buildings 100 :settable) (number-of-x-sections 5 :settable) (number-of-y-sections 3 :settable) (proximity-rules *proximity-rules* :settable)) :computed-slots ((corner (translate (the base center) :up (half (the base height)) :left (half (the base width)) :front (half (the base length)))) (buildings-data (let (result) (dotimes (n (the number-of-buildings) (nreverse result)) (push (the (generate-building-data :height-min 10 :height-max 50 :width-min 20 :width-max 75 :length-min 20 :length-max 75)) result)))) (sections-ht (let ((ht (make-hash-table))) (dolist (building (list-elements (the buildings)) ht) (push building (gethash (the-object building section) ht))))) (ui-display-list-objects (cons (the base) (append (list-elements (the buildings)) (list-elements (the sections))))) (minimum-distance (let (result) (dolist (building (list-elements (the buildings)) result) (when (and (the-object building minimum-distance) (or (null result) (< (first (the-object building minimum-distance)) (first result)))) (setq result (append (the-object building minimum-distance) (list building)))))))) :objects ((base :type 'box :center (translate (the center) :down (half (the height))) :display-controls (list :color :green :transparency 0.2)) (buildings :type (:sequence (mapcar #'(lambda(plist) (getf plist :type)) (the buildings-data))) :sequence (:size (length (the buildings-data))) :data (nth (the-child index) (the buildings-data)) :section (the (compute-section-for-building (the-child))) :closest? (member (the-child) (the minimum-distance)) :height (getf (the-child data) :height) :width (getf (the-child data) :width) :length (getf (the-child data) :length) :center (getf (the-child data) :center) :pass-down (proximity-rules)) (minimum-distance-rule :type 'gwl-rule-object :rule-title "Min. Dist." :rule-description "Closest Pair of Buildings" :rule-result (format nil "~a to ~a: ~2,1f" (the-object (second (the minimum-distance)) index) (the-object (third (the minimum-distance)) index) (first (the minimum-distance))) :violated? t) (sections :type 'grid-section :sequence (:matrix :lateral (the number-of-x-sections) :longitudinal (the number-of-y-sections)) :width (/ (the width) (the number-of-x-sections)) :length (/ (the length) (the number-of-y-sections)) :buildings-list (gethash (the-child) (the sections-ht)) :center (translate (the base (vertex :top :left :front)) :right (+ (half (the-child width)) (* (the-child width) (first (the-child index)))) :rear (+ (half (the-child length)) (* (the-child length) (second (the-child index))))))) :functions ((compute-section-for-building (building) (let ((section-indices (list (floor (div (+ (half (the width)) (get-x (the-object building center)) ) (the (sections 0 0) width))) (floor (div (+ (half (the length)) (get-y (the-object building center)) ) (the (sections 0 0) length)))))) (the (sections (first section-indices) (second section-indices))))) (generate-building-data (&key height-min height-max width-min width-max length-min length-max (base-width (the base width)) (base-length (the base length))) (let* ((type (ecase (random 2) (0 'school) (1 'pub))) (height (+ (random (1+ (- height-max height-min))) height-min)) (width (+ (random (1+ (- width-max width-min))) width-min)) (length (+ (random (1+ (- length-max length-min))) length-min)) (center (translate (the corner) :up (half height) :right (+ (half width) (random (- (1+ base-width) width))) :rear (+ (half length) (random (- (1+ base-length) length)))))) (list :type type :height height :width width :length length :center center))))) (define-lens (html-format assembly)() :output-functions ((model-inputs () (html (:table (:tr ((:td :bgcolor :yellow) "Width") (:td ((:input :type :string :name :width :value (the width))))) (:tr ((:td :bgcolor :yellow) "Length") (:td ((:input :type :string :name :length :value (the length))))) (:tr ((:td :bgcolor :yellow) "# of Buildings") (:td ((:input :type :string :name :number-of-buildings :value (the number-of-buildings))))) (:tr ((:td :bgcolor :yellow) "# of Sections") (:td ((:input :type :string :name :number-of-x-sections :value (the number-of-x-sections)))))) (:p (:center ((:input :type :submit :name :submit :value "OK"))))))))
5,061
Common Lisp
.lisp
123
34.447154
98
0.621934
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8849529517e89f44f52c79841a7812ee9710e1372dcf979eac73e6e76e12c8eb
36,195
[ -1 ]
36,196
building.lisp
lisp-mirror_gendl/documentation/training/g102/solutions/city/source/building.lisp
(in-package :city) ;; ;; This version is slightly better than the original city because we ;; don't have any rule data hardcoded and we have "factored out" ;; repeated code. However from a performance standpoint it still ;; could be better -- note how each building instance of a given type ;; will recompute its applicable-rules-data, which will be identical ;; for all buildings of a given type. This could be done once in the ;; parent object, and the applicable-rules-data passed into building ;; as an :input-slot. This is not an assignment but we will do it as a ;; group exercise. ;; (eval-when (:compile-toplevel :load-toplevel :execute) (define-object proximity-rule () :input-slots (current-building neighbors target-type distance rule-data) :computed-slots ((minimum-distance (let (result) (dolist (building (the violated-buildings) result) (let ((distance (3d-distance (the current-building center) (the-object building center)))) (when (or (null result) (< distance (first result))) (setq result (list distance building))))))) (violated? (not (null (the violated-buildings)))) ;; ;; This will end up as a list of other buildings which violate the ;; proximity rule. It can also be nil, which is the same as the ;; empty list, if no buildings are close enough to violate. ;; (violated-buildings (let (result) (dolist (building (the neighbors) (nreverse result)) (when (and (typep building (the target-type)) (not (eql building (the current-building))) (< (3d-distance (the current-building center) (the-object building center)) (the distance))) (push building result)))))))) (define-object building (box) :input-slots (section proximity-rules closest?) :computed-slots (;; ;; catch-all color for any non-specific buildings or building sub-types ;; with no color specified. ;; (color :black) (display-controls (list :color (if (the closest?) :purple (the color)) :line-thickness (if (the any-rules-violated?) 3 1))) (neighbors (the section nearby-buildings)) ;; Returns non-nil if this object violates any rules ;; (any-rules-violated? (some #'(lambda(rule) (the-object rule violated?)) (list-elements (the rules)))) ;; ;; Returns a list of rules which apply to this type of object ;; (applicable-rules-data (remove-if-not #'(lambda(rule) (eql (first rule) (the type))) (the proximity-rules))) (minimum-distance (let (result) (dolist (rule (list-elements (the rules)) result) (when (and (the-object rule minimum-distance) (or (null result) (< (first (the-object rule minimum-distance)) (first result)))) (setq result (the-object rule minimum-distance))))))) :hidden-objects ( ;; Now we have a child object to compute the rule, rather than just ;; a computed-slot. Pushing the work into a child object is similar ;; in concept to calling a function or subroutine in a procedural ;; language. ;; ;; This is defined as a sequence, in case more than one rule ;; matches for this building type. ;; ;; In our current example only one rule will match for pub and one ;; for school, so the sequence will only have one element. ;; (rules :type 'proximity-rule :sequence (:size (length (the applicable-rules-data))) :pass-down (neighbors) :rule-data (nth (the-child index) (the applicable-rules-data)) :target-type (second (the-child rule-data)) :distance (third (the-child rule-data)) :current-building self))) (define-object school (building) :computed-slots ((color :blue))) (define-object pub (building) :computed-slots ((color :red)))
3,884
Common Lisp
.lisp
91
36.824176
89
0.678062
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
35a52866dc287601db638999b3aaf9f8765a8c2f5106ecbd2b0795bc102272e6
36,196
[ -1 ]
36,199
ackermann-assembly.lisp
lisp-mirror_gendl/documentation/training/g102/solutions/ackermann/source/ackermann-assembly.lisp
(in-package :ackermann) (define-object assembly (box) :documentation (:description "Schematic of a typical truck steering system.") :input-slots (("List of 3D points. Enables direct placement of the kingpin axes." kingpin-centers (list :left (make-point 0 -200 0) :right (make-point 0 200 0))) ("List of keyword and number. Indicates current turn state of the mechanism." current-rotation-angle 30 :settable)) :computed-slots ((self-center (midpoint (getf (the kingpin-centers) :left) (getf (the kingpin-centers) :right))) (length (3d-distance (getf (the kingpin-centers) :left) (getf (the kingpin-centers) :right))) (tie-rod-length (3d-distance (the known-linkage-object straight-ahead-tie-rod-arm-ball-center) (the other-linkage-object straight-ahead-tie-rod-arm-ball-center))) (width 100) (height 100) (known-linkage-object (the (linkages 0))) (known-linkage-object-sphere (the known-linkage-object tie-rod-ball-socket-sphere)) (other-linkage-object (the (linkages (- 1 (the known-linkage-object :index))))) (other-linkage-object-circle (the other-linkage-object tie-rod-arm-ball-articulation-circle)) (other-tie-rod-ball-location (inter-circle-sphere (the other-linkage-object-circle center) (the other-linkage-object-circle radius) (the other-linkage-object-circle (face-normal-vector :top)) (the known-linkage-object-sphere center) (the known-linkage-object-sphere radius) nil)) (other-tie-rod-rotation (angle-between-vectors-d (the other-linkage-object straight-ahead-tie-rod-arm-vector) (subtract-vectors (the other-tie-rod-ball-location) (the other-linkage-object tie-rod-arm-pivot-point)) (the other-linkage-object kingpin-axis) t))) :objects ( (ball :type 'sphere :display-controls (list :color :red) :center (the other-tie-rod-ball-location) :radius 10) (tie-rod :type 'c-cylinder :radius 1 :start (the (linkages 0) tie-rod-arm-ball-center) :end (the (linkages 1) tie-rod-arm-ball-center)) (linkages :type 'simple-linkage :sequence (:size 2) :side (ecase (the-child index) (0 :left) (1 :right)) :tie-rod-length (the tie-rod-length) :kingpin-center (getf (the kingpin-centers) (the-child side)) :current-rotation-angle (if (eql (the-child side) :left) (the current-rotation-angle) (the other-tie-rod-rotation)))))
2,466
Common Lisp
.lisp
46
47.369565
112
0.696831
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0b1c1297f9e6a3caab48237e63d1557befc960856d931f2a75e2a32664606617
36,199
[ -1 ]
36,201
publish.lisp
lisp-mirror_gendl/documentation/training/g102/source/publish.lisp
(in-package :training-g102) (publish :path "/training-g102" :function #'(lambda(req ent) (gwl-make-object req ent "training-g102:assembly"))) (print-variables *load-truename*) (defparameter *images-path* (merge-pathnames "documentation/training/g102/images/" glisp:*gendl-source-home*)) (publish-directory :prefix "/g102/images/" :destination (format nil "~a" *images-path*)) (defun push! () (glisp:run-shell-command "rm -r /tmp/sites/") (gwl:crawl "training-g102:assembly") (glisp:run-shell-command "mv /tmp/sites/assembly/ /tmp/sites/training-g102/") (glisp:run-shell-command "rsync -zav /tmp/sites/training-g102/ genworks.com:kitchen/downloads/training-g102/") (glisp:run-shell-command "rm -r /tmp/sites/"))
752
Common Lisp
.lisp
14
49.785714
112
0.723375
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e496c8fd504605a78381a938fa31a18bad36525437a9445d34be98555c15bc4d
36,201
[ -1 ]
36,202
example-1.lisp
lisp-mirror_gendl/documentation/training/legacy/gdl/source/example-1.lisp
;; ;; Copyright 2002, 2009, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-tutorial) (defparameter *example-1* `((:chapter :title "Example 1: Personal Ledger") "In this chapter we will describe a simple personal accounting ledger application. First we will build the core objects necessary to keep track of accounts and transactions; then we will layer a web user interface on top of these objects to allow for convenient end-user access. I have chosen to build this application in base GDL/GWL, without the use of any database" (:footnote (:indexed "Paul Graham") " is fond of reminding us that ``the filesystem is already a database.''") " or other general-purpose mixins. Clearly, one could greatly reduce the amount of code required for an application like this by using ``utility'' mixins for tasks such as database or filesystem access and standard GUI templates. While it certainly does not implement the most efficient accounting/ledger algorithms possible, this application will give us a small taste of the power of the caching and dependency-tracking features of a KB system." ((:section :title "Main Ledger Object") "The full source for the Ledger application is available in the GDL application directory under the " (:texttt "gwl-samples") " directory. We include partial hardcopy in this tutorial, but if you wish to try running the example yourself you should use the code from the CD rather than trying to type it in from this hardcopy (also, some changes may have occured since the preparation of this tutorial). The ledger application needs write access to files under the " (:texttt "gwl-samples/ledger/data/") " directory, so you may need to open up permissions on these files, or copy the entire " (:texttt "ledger/") " directory to a location where you have write access, such as your home directory. Figure " (:ref "code:ledger-input-computed") " shows the input-slots and computed-slots of our main object, named conventionally ``assembly'' (in the " (:texttt ":ledger") " Lisp package). The two inputs each default to a file holding the beginning data set for Accounts and Transactions respectively. Figure " (:ref "data:ledger-data") " shows a sampling of the first few lines from typical data files. These data files are given the ``lisp'' extension simply so that they will come up in Lisp-mode in Emacs for ease of hand-editing -- they are not meant to be compiled as Lisp program source code. The " (:texttt "account-data") " and " (:texttt "transaction-data") " computed-slots read and hold the contents of these data files for use in initializing the actual " (:texttt "accounts") " and " (:texttt "transactions") " object sequences, which the ledger application will use. The " (:texttt "account-indices") " and " (:texttt "transaction-indices") " collect up the unique indices from the individual acounts and transactions, used to compute the ``next'' index when adding a new ``record.'' The " (:texttt "net-worth") " and " (:texttt "profit") " slots compute the sums of Asset/Liability accounts and Income/Expense accounts, respectively (the sign on " (:texttt "profit") " is reversed to make Income items appear positive and Expense items appear negative). Finally, the " (:texttt "balances-hash-table") " slot is a hash table keyed on the account indices, computing the current balance of each account. This value is passed into the actual account objects for later use." ((:boxed-figure :caption "Contents of Account and Transaction Data Files" :label "data:ledger-data") (:verbatim " (\"Index\" \"Name\" \"Description\" \"Account Number\" \"Account Type\" \"Account Class\" \"Beginning Balance\") (0 \"DFCU\" \"Dearborn Federal Credit Union\" \"999-6969-999\" \"Checking\" \"Asset/Liability\" 25000) (1 \"Waterhouse\" \"Waterhouse Taxable\" \"555-7979-555\" \"Savings\" \"Asset/Liability\" 12500) ... (\"Index\" \"From Account\" \"To Account\" \"Date\" \"Amount\" \"Payee\") (0 0 1 3243976597 1000 \"djc\") (1 0 1 3243976772 1500 \"djc\") ... ")) (:define-object assembly-1) ((:boxed-figure :caption "Input-Slots and Computed-Slots of Ledger" :label "code:ledger-input-computed") (:small (:define-object assembly-1)) #+nil (:small (:verbatim " (define-object assembly (base-object) :input-slots ((account-data-file \"~/genworks/gwl-apps/ledger/data/accounts.lisp\") (transaction-data-file \"~/genworks/gwl-apps/ledger/data/transactions.lisp\")) :computed-slots ((account-data (let (result) (with-open-file (in (the account-data-file)) (do ((account (read in nil nil) (read in nil nil))) ((null account) (nreverse result)) (push account result))))) (transaction-data (let (result) (with-open-file (in (the transaction-data-file)) (do ((transaction (read in nil nil) (read in nil nil))) ((null transaction) (nreverse result)) (push transaction result))))) (account-indices (mapcar #'(lambda(account) (the-object account index)) (list-elements (the accounts)))) (transaction-indices (mapcar #'(lambda(transaction) (the-object transaction index)) (list-elements (the transactions)))) (net-worth (let ((result 0)) (dolist (account (list-elements (the accounts)) result) (when (eql (make-keyword (the-object account account-class)) :asset/liability) (incf result (the-object account current-balance)))))) (profit (let ((result 0)) (dolist (account (list-elements (the accounts)) result) (when (eql (make-keyword (the-object account account-class)) :income/expense) (decf result (the-object account current-balance)))))) (balances-hash-table (let ((ht (make-hash-table))) (dolist (account (list-elements (the accounts))) (setf (gethash (the-object account index) ht) (the-object account beginning-balance))) (dolist (transaction (list-elements (the transactions)) ht) (decf (gethash (the-object transaction from-account) ht) (the-object transaction amount)) (incf (gethash (the-object transaction to-account) ht) (the-object transaction amount)))))) ... "))) "Figure " (:ref "fig:genacc2-subobjects") " shows the two sub-objects contained within the ledger assembly object. Each of these is specified as a " (:texttt (:indexed "sequence")) ", based on the initial data read from the data files. Because these sequences are specified by a list of " (:texttt (:indexed ":indices")) ", rather than by a fixed " (:texttt (:indexed ":size")) ", they can be programmatically modified by inserting and deleting sequence elements. In this example, such insertions or deletions would be analogous to row operations on a relational database table. Note that the " (:texttt "current-balance") " is accessed from the " (:texttt "balances-hash-table") ", a computed-slot listed in Figure " (:ref "code:ledger-input-computed") "." ((:boxed-figure :caption "Sub-Objects of Ledger" :label "fig:genacc2-subobjects") (:small (:verbatim " ... :objects ((accounts :type 'account :sequence (:indices (mapcar #'first (rest (the account-data)))) :data (nth (the-child index) (rest (the account-data))) :current-balance (gethash (the-child index) (the balances-hash-table)) :headings (first (the account-data))) (transactions :type 'transaction :sequence (:indices (mapcar #'first (rest (the transaction-data)))) :data (nth (the-child index) (rest (the transaction-data))) :headings (first (the transaction-data)))) ... "))) "The final segment of our main ledger object is listed in Figure " (:ref "fig:genacc2-functions") ". Here, we specify some functions on the ledger object which accept arguments and perform some side-effect on the object. Note that GDL " (:texttt ":functions") " are distinguished from " (:texttt ":computed-slots") " by two main characteristics:" ((:list :style :enumerate) (:item "They can accept arguments, a ``lambda list,'' as with a normal CL function.") (:item "Their return-values are not cached or dependency-tracked. Their bodies are evaluated every time they are referenced (called).")) "The " (:texttt "add-transaction!") " function adds a new transaction element to the " (:texttt "transactions") " object sequence, and immediately calls the " (:texttt "save-transactions!") " function to update the transactions data file" (:footnote "In a more robust application, the in-memory insertion and the updating of the external file should be done as an indivisible unit with ``unwind'' capability, to ensure that either the whole thing succeeds or the whole thing fails.") ". The most important thing to note here is that when a new transaction is added using the " (:texttt "add-transaction!") " function, any other message (e.g. computed-slot, object, etc.) which in any way depends upon the " (:texttt "transactions") (:index "recomputation!on-demand") " sequence of objects will now automatically recompute and return a fresh value the next time it is demanded. For example, the " (:texttt "profit") " and " (:texttt "net-worth") " messages will now return updated values the next time they are demanded. But the recomputation of a message will happen if and only if the message is actually demanded. In a very large object tree, for example, thousands of messages in hundreds of objects might depend on a certain value. When that value is changed, however, the system " (:underline "does not") " incur the computational overhead of updating all these thousands of dependent items at that time. Perhaps only a few dozen of these thousands of dependent items will ever be accessed. Only those few dozen will need to be computed. This is one of the obvious distinctions between a conventional ``spreadsheet'' application and a knowledge base application --- a spreadsheet is generally not scalable to very large problems or models, because changing a value forces the user to wait for an all-or-nothing update of the entire sheet." (:index "spreadsheet!KB as distinct from") ((:boxed-figure :caption "Functions of Ledger" :label "fig:genacc2-functions") (:small (:verbatim " ... :functions ((add-transaction! (&key from-account to-account date amount payee) (when (or (not (member from-account (the account-indices))) (not (member to-account (the account-indices))) (not (numberp amount)) (not (stringp payee)) (not (ignore-errors (decode-universal-time date)))) (error \"One or more invalid arguments given to add-transaction!\")) (let ((new-index (1+ (if (null (the transaction-indices)) 0 (apply #'max (the transaction-indices)))))) (the transactions (insert! new-index)) (the (transactions new-index) (set-slot! :data (list new-index from-account to-account date amount payee)))) (the save-transactions!)) (save-transactions! () (with-open-file (out (the transaction-data-file) :direction :output :if-exists :supersede :if-does-not-exist :create) (print (first (the transaction-data)) out) (dolist (transaction (list-elements (the transactions))) (print (the-object transaction data) out)))) ;; ... Similarly for add-account! and save-accounts! ))) ")))) ((:section :title "Objects for Accounts and Transactions") "Figure " (:ref "fig:genacc2-accountandtransaction") " shows the object definitions for " (:texttt "account") " and " (:texttt "transaction") ". These are simple objects which essentially receive some inputs and make them available as messages." ((:boxed-figure :caption "Account and Transaction Object Definitions" :label "fig:genacc2-accountandtransaction") (:verbatim " (define-object account (base-object) :input-slots (data headings current-balance) :computed-slots ((name (second (the data))) (description (third (the data))) (account-number (fourth (the data))) (account-type (fifth (the data))) (account-class (sixth (the data))) (beginning-balance (seventh (the data))))) (define-object transaction (base-object) :input-slots (data headings) :computed-slots ((from-account (second (the data))) (to-account (third (the data))) (date (fourth (the data))) (amount (fifth (the data))) (payee (sixth (the data))))) "))) ((:section :title "Using the Main Ledger Object") "We can use the ledger object we have put together so far by typing commands at the Common Lisp prompt. First, we will make an instance of a ledger object, conveniently setting this instance to the variable " (:texttt "self") ":" (:verbatim " LEDGER(10): (setq self (make-object 'assembly)) #<ASSEMBLY @ #x7367516a>") "Now we can use ``the'' referencing to call various messages in this instance:" (:verbatim " LEDGER(11): (the profit) 140 LEDGER(12): (the net-worth) 37640 LEDGER(13): (the balances-hash-table) #<EQL hash-table with 7 entries @ #x7367fc1a> LEDGER(14): (the (accounts 0) current-balance) 28140 LEDGER(15):") "Now we will add a transaction, and confirm that it affects our " (:texttt "profit") " and " (:texttt "net-worth") ":" (:verbatim " LEDGER(15): (the (add-transaction! :from-account 0 :to-account 4 :date (get-universal-time) :amount 250 :payee \"djc\")) NIL LEDGER(16): (the profit) -110 LEDGER(17): (the net-worth) 37390 LEDGER(18):") "If we had wrapped the CL " (:index "time!using to understand KB dynamics") (:texttt "time") " macro around for example the call to the " (:texttt "profit") ", we would have been able to see that indeed it was recomputed the second time we called it, since something it depends upon had been modified. If we call it again immediately, without having changed anything, " (:texttt "time") " would show us that it returns virtually instantaneously without causing any substantial work to be done, since its value is now cached and the cache is still fresh.") ((:section :title "Making a Web Interface with GWL") "Now that we have built and tested our main ledger ``engine,'' let's make it more accessible to casual users by layering a web user interface on it. One way to do this is to create a new toplevel object which " (:emph "contains") " the ledger engine, and specifies an assembly of objects to represent the web pages in our interface. Figure " (:ref "code:ledger-html-top") " shows the definition of the top level, or ``home page,'' of our web application. It contains the actual ledger assembly, or ``engine,'' as well as child objects, which represent sub-pages in our website, corresponding to an account listing, a transaction listing, a form for adding a transaction, and a form for adding an account." ((:boxed-figure :caption "Slots and Object for Web Interface" :label "code:ledger-html-top") (:verbatim " (define-object html-assembly (base-html-sheet) :computed-slots ((accounts-ht (let ((ht (make-hash-table))) (dolist (account (list-elements (the ledger accounts)) ht) (setf (gethash (the-object account index) ht) account))))) :objects ((ledger :type 'assembly) (view-accounts :type 'view-accounts :account-sequence (the ledger accounts)) (view-transactions :type 'view-transactions :transaction-sequence (the ledger transactions) :pass-down (accounts-ht)) (add-transaction :type 'add-transaction :main-sheet self :pass-down (accounts-ht)) (add-account :type 'add-account :main-sheet self)) ... ")) "Our toplevel user interface sheet also contains a " (:texttt "write-html-sheet") " presentation function, shown in Figure " (:ref "code:ledger-html-bottom") ". This presentation function also serves as a response function to the forms for adding accounts and transactions -- for this reason, it contains two blocks of code, before the actual html page generation, which take care of actually processing any added transaction or account. The form values for these will show up as plist values in the " (:texttt "query-plist") " slot, since they are not specified as named slots in the objects which generate the forms (the transaction form is shown in Figure " (:ref "code:add-transactions-sheet") ", and the accounts form is not listed here but is similar)." ((:boxed-figure :caption "Output Function for Web Interface" :label "code:ledger-html-bottom") (:small (:verbatim " :functions ((write-html-sheet () (let ((plist (the add-transaction query-plist))) (when plist (the ledger (add-transaction! :from-account (read-safe-string (getf plist :from-account)) :to-account (read-safe-string (getf plist :to-account)) :date (iso-to-universal (getf plist :date)) :amount (read-safe-string (getf plist :amount)) :payee (getf plist :payee)))) (the add-transaction (:set-slot! :query-plist nil))) (let ((plist (the add-account query-plist))) (when plist (the ledger (add-account! :name (getf plist :name) :description (getf plist :description) :account-number (getf plist :account-number) :account-type (getf plist :account-type) :account-class (getf plist :account-class) :beginning-balance (read-safe-string (getf plist :beginning-balance))))) (the add-account (:set-slot! :query-plist nil))) (html (:html (:head (:title \"Personal Ledger\")) (:body (:h2 (:center \"Personal Ledger\")) (:p (:table (:tr (:td \"Net Worth:\") ((:td :align :right) (:b (:tt ((:font :color (gethash (if (minusp (the ledger net-worth)) :red :green-lime) *color-table*)) (:princ (number-format (the ledger net-worth) 2))))))) (:tr (:td \"Profit/Loss:\") ((:td :align :right) (:b (:tt ((:font :color (gethash (if (minusp (the ledger profit)) :red :green-lime) *color-table*)) (:princ (number-format (the ledger profit) 2))))))))) (:p (:ul (:li (the view-accounts (write-self-link :display-string \"View Accounts\"))) (:li (the view-transactions (write-self-link :display-string \"View Transactions\"))) (:li (the add-transaction (write-self-link :display-string \"Add Transaction\"))) (:li (the add-account (write-self-link :display-string \"Add Account\"))))))))))) "))) ((:image-figure :image-file "ledger-main.png" :caption "Main Screen of Ledger" :label "fig:ledger-main")) ((:image-figure :image-file "transaction-listing.png" :caption "Transaction Listing Sheet" :label "fig:transaction-listing")) "Figure " (:ref "code:view-transactions-sheet") " defines an object which takes two inputs and computes two simple slots, but most of all it defines a presentation method to generate an html table listing all transactions entered to date. An example is seen in Figure " (:ref "fig:transaction-listing") "." ((:boxed-figure :caption "Sheet for Transaction Listing" :label "code:view-transactions-sheet") (:verbatim " (define-object view-transactions (base-html-sheet) :input-slots (transaction-sequence accounts-sequence) :computed-slots ((transactions (list-elements (the transaction-sequence))) (headings (the-object (first (the transactions)) headings))) :functions ((write-html-sheet () (html (:html (:head (:title \"Transaction Listing\")) (:body (:h2 (:center \"Transaction Listing\")) (:p (the (:write-back-link))) (:p ((:table :bgcolor :black) ((:tr :bgcolor :yellow) (dolist (heading (rest (the headings))) (html (:th (:princ heading))))) (dolist (transaction (the transactions)) (html ((:tr :bgcolor (gethash :grey-light-very *color-table*)) (dolist (slot (list :from-account :to-account :date :amount :payee )) (let* ((raw-value (the-object transaction (evaluate slot))) (value (case slot ((:from-account :to-account) (the :accounts-sequence (get-member raw-value) :name)) (:date (iso-date raw-value)) (:amount (number-format raw-value 2)) (otherwise raw-value)))) (html ((:td :align (case slot (:amount :right) (otherwise :left))) (case slot (:amount (html (:tt (format *html-stream* \"$~$\" value)))) (otherwise (html (:princ value))))))))))))) (:p (the (:write-back-link))))))))) ")) "Figure " (:ref "code:add-transactions-sheet") " defines a presentation function to create a fillout-form for adding a transaction, and Figure " (:ref "fig:add-transaction") " shows a sample rendition of this form." ((:boxed-figure :caption "Form for Adding a Transaction" :label "code:add-transactions-sheet") (:small (:verbatim " (define-object add-transaction (base-html-sheet) :input-slots (accounts-sequence main-sheet) :computed-slots ((respondent (the main-sheet))) :functions ((write-html-sheet () (html (:html (:head (:title \"Add Transaction\")) (:body (:h2 (:center \"Add Transaction\")) (:p (the (:write-back-link))) (with-html-form (:p ((:table :bgcolor :black) (:tr ((:td :bgcolor :yellow) \"From Account\") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:select :name :from-account) (mapcar #'(lambda(account) (html ((:option :value (the-object account index)) (:princ (the-object account name))))) (list-elements (the accounts-sequence)))))) (:tr ((:td :bgcolor :yellow) \"To Account\") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:select :name :to-account) (mapcar #'(lambda(account) (html ((:option :value (the-object account index)) (:princ (the-object account name))))) (list-elements (the accounts-sequence)))))) (:tr ((:td :bgcolor :yellow) \"Date\") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:input :type :text :name :date :size 12 :value (iso-date (get-universal-time)))))) (:tr ((:td :bgcolor :yellow) \"Amount\") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:input :name :amount :type :text :size 15)))) (:tr ((:td :bgcolor :yellow) \"Payee\") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:input :name :payee :type :text :size 30)))))) (:p ((:input :type :submit :name :add-transaction :value \" Add! \")))))))))) "))) ((:image-figure :image-file "add-transaction.png" :caption "Form for Adding a Transaction" :label "fig:add-transaction")) ) ((:section :title "Summary") " Please note that we have built this ledger using only core GDL/GWL, for illustrative purposes. Several parts of the app have been written from scratch, which otherwise could be handled by using simple utilities or libraries for things such as filesystem/database access and user interface templates. " (:index "mainstream apps!KB technology useful for") (:index "requirements!ever-expanding") "The main point of this example is to show that KB technology can be useful even for applications which might be considered ``simple'' or ``mainstream'' --- even the simplest of applications tend to grow ever-changing and ever-expanding requirements, and it pays in the end to use a development environment which can absorb these requirements gracefully and with ease.")))
28,784
Common Lisp
.lisp
587
37.664395
109
0.5985
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d6227cf6cc6714b9e3612fb8698936e9ef9e0be351d8ed1ce231f9a6f9514628
36,202
[ -1 ]
36,203
assembly.lisp
lisp-mirror_gendl/documentation/training/legacy/gdl/source/assembly.lisp
;; ;; Copyright 2002, 2009, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-tutorial) (defparameter *data* `((:document :class ("11pt" "book") :textwidth 6.5 :topmargin 0 :textheight 8.5 :oddsidemargin 0 :evensidemargin 0 :pdfimageresolution "135" :title "Genworks GDL Tutorial" :author "David J. Cooper, Jr." :usepackage ("dvips" "graphicx") :usepackage ("usenames, dvipsnames" "color") :usepackage ("makeidx") :newsavebox ("\\boxedverb") :makeindex nil) :frontmatter :maketitle (:footnotetext "Copyright " (:copyright) " 2002, Genworks International. Duplication, by any means, in whole or in part, requires written consent from Genworks International.") :tableofcontents :mainmatter ,*introduction* ,*gdl-syntax* ,*gwl-syntax* ,*example-1* ;; nongeometric ,*example-2* ;; robot ,*example-3* ;; school bus :backmatter :printindex )) (defun make (&optional (level 1)) (load "~/gendl/documentation/training/legacy/gdl/source/assembly.lisp") (let ((object (make-part 'com.genworks.dom:assembly :data *data*))) (ensure-directories-exist (translate-logical-pathname "~/gendl/documentation/training/legacy/gdl/pdf/")) (with-open-file (out "~/gendl/documentation/training/legacy/gdl/pdf/tutorial.tex" :direction :output :if-exists :supersede :if-does-not-exist :create) (with-format (com.genworks.dom-writers:latex out) (write-the-object object (:base))))) (excl:run-shell-command (format nil "cd ~a; pdflatex tutorial.tex" (translate-logical-pathname "~/gendl/documentation/training/legacy/gdl/pdf/"))) (excl:run-shell-command (format nil "cd ~a; makeindex tutorial" (translate-logical-pathname "~/gendl/documentation/training/legacy/gdl/pdf/"))) (dotimes (n level) (excl:run-shell-command (format nil "cd ~a; pdflatex tutorial.tex" (translate-logical-pathname "~/gendl/documentation/training/legacy/gdl/pdf/"))))) (define-object assembly (com.genworks.dom:assembly) :input-slots ((data *data*))) (publish :path "/dom-doc" :function #'(lambda(req ent) (gwl-make-object req ent "gdl-tutorial:assembly")))
3,029
Common Lisp
.lisp
76
35.671053
108
0.706685
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c1fd4a9827c6e44ed0ea431bcc273356a033e33e5138834f9c9b25f21167123e
36,203
[ -1 ]
36,204
package.lisp
lisp-mirror_gendl/documentation/training/legacy/gdl/source/package.lisp
;; ;; Copyright 2002, 2009, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :cl) (gwl:define-package :gdl-tutorial (:export #:assembly #:make))
927
Common Lisp
.lisp
22
40.954545
70
0.758583
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8a9af6b6f8d27ea7186f582f111cbc170730d49cc5b1fc0441c7f1334660fb6d
36,204
[ -1 ]
36,205
introduction.lisp
lisp-mirror_gendl/documentation/training/legacy/gdl/source/introduction.lisp
;; ;; Copyright 2002, 2009, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-tutorial) (defparameter *introduction* `((:chapter :title "Introduction") ((:section :title "Knowledge Base Concepts According to Genworks") "You may have an idea from college or from textbooks that Knowledge Base Systems, or Knowledge " (:emph "Based") " Systems, are a broad or fuzzy set of concepts somehow related to " (:indexed "AI") " which ``do not translate into anything practical.'' Or you may have heard jabs at the pretentious-sounding name, " "Knowledge-based Engineering" " as in: ``you mean as opposed to " (:indexed "Ignorance-based Engineering") "?'' To the contrary, we hope you will agree that our concept of a KB system is simple and practical, and in this tutorial our goal is to make you comfortable and excited about the ideas we have implemented in our flagship system, GDL/GWL. Our definition of a " (:emph (:indexed "Knowledge Base System")) " is an object-oriented programming environment which implements the features of " (:emph (:indexed "Caching")) " and " (:emph (:indexed "Dependency tracking")) ". Caching means that once the KB has computed something, it might not need to repeat that computation if the same question is asked again. Dependency tracking is the flip side of that coin --- it ensures that if a cached result is " (:emph "stale") ", the result will be recomputed the next time it is " (:emph "demanded") ", so as to give a fresh result.") ((:section :title "Goals for this Tutorial") "This manual is designed as a companion to a live two-hour GDL/GWL tutorial, but you may also be reading it on your own. In either case, the basic goals are:" ((:list :style :itemize) (:item "Get you excited about using GDL/GWL") (:item "Enable you to judge whether GDL/GWL is an appropriate tool for a given job") (:item "Arm you with the ability to argue the case for using GDL/GWL when appropriate") (:item "Prepare you to begin maintaining and authoring GDL/GWL applications, or porting apps from similar KB systems into GDL/GWL.")) "This tutorial assumes a basic familiarity with the " (:indexed "Common Lisp") " programming language. If you are new to Common Lisp: congratulations! You have just discovered an exciting and powerful new tool. Many resources are available to get you started in CL --- for starters, we recommend " (:underline (:indexed "Basic Lisp Techniques") ) (:footnote (:underline "BLT") " is available at " (:texttt "http://www.franz.com/resources/educational_resources/cooper.book.pdf")) ", which was prepared by the author of this tutorial. " "Most of the Common Lisp used in this tutorial is covered in the first few chapters of " (:underline "Basic Lisp Techniques") ", and there you will also find pointers to more exhaustive CL tutorials and reference material.") ((:section :title "What is GDL/GWL?") "GDL is an acronym for the General-purpose Declarative Language. GWL is an acronym for the Generative Web Language. GWL ships along with GDL in a layered, modular fashion. For the remainder of this tutorial, we will sometimes refer only to GDL, and this should usually be taken to mean the bundled package which includes GWL. GDL is a superset of ANSI Common Lisp, and consists mainly of automatic code-expanding extensions to Common Lisp implemented in the form of macros. When you write, let's say, 20 lines in GDL, you might be writing the equivalent of 200 lines of Common Lisp. Of course, since GDL is a superset of Common Lisp, you still have the full power of the CL language at your fingertips whenever you are working in GDL. " (:index "compiled language!benefits of") (:index "macros!code-expanding") "Since GDL expands into CL, everything you write in GDL will be compiled ``down to the metal'' to machine code with all the optimizations and safety that the tested-and-true CL compiler provides. This is an important distinction as contrasted to some other so-called KB systems on the market, which are really nothing more than interpreted scripting languages which often fall over with a ``thud'' when pushed to compute something more demanding than simple parameter-passing. GDL can also be considered a " (:emph (:indexed "declarative")) " language. When you put together a GDL application, you write and think mainly in terms of objects and their properties, and how they depend on one another in a direct sense. You do not have to track in your mind explicitly how one object or property will ``call'' another object or propery, in what order this will happen, etc. Those details are taken care of for you automatically by the language. Because GDL is object-oriented, you have all the features you would normally expect from an object-oriented language, such as " ((:list :style :itemize) (:item "Separation between the " (:emph "definition") " of an object and an " (:emph "instance") " of an object") (:item "High levels of data abstraction") (:item "The ability for one object to ``inherit'' from others") (:item "The ability to ``use'' an object without concern for its ``under-the-hood'' implementation")) (:index "object-orientation!message-passing") (:index "object-orientation!generic-function") "GDL supports the ``message-passing'' paradigm of object orientation, with some extensions. Since full-blown ANSI CLOS (Common Lisp Object System) is always available as well, the Generic Function paradigm is supported as well. Do not be concerned at this point if you are not fully aware of the differences between these two paradigms" (:footnote "See Paul Graham's " (:underline "ANSI Common Lisp") ", page 192, for an excellent discussion of the Two Models of Object-oriented Programming.") ".") ((:section :title "Why GDL (what is GDL good for?)") ((:list :style :itemize) (:item "Organizing and interrelating large amounts of information in ways not possible or not practical using conventional languages or conventional relational database technology alone;") (:item "Evaluating many design or engineering alternatives and performing various kinds of optimizations within specified design spaces;") (:item "Capturing the procedures and rules used to solve repetitive tasks in engineering and other fields;") (:item "Applying rules to achieve intermediate and final outputs, which may include virtual models of wireframe, surface, and solid geometric objects."))) ((:section :title "What GDL is not") ((:list :style :itemize) (:item "A CAD system (although it may operate on and/or generate geometric entities);") (:item "A drawing program (although it may operate on and/or generate geometric entities);") (:item "An Artificial Intelligence system (although it is an excellent environment for developing capabilities which could be considered as such);") (:item "An Expert System Shell (although one could be easily embedded within it)."))) "Without further ado, then, let's turn the page and get started with some hands-on GDL..."))
8,201
Common Lisp
.lisp
142
53.147887
108
0.738098
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8323a71efb06842f8072e9f43b042057392113aa30f28b6c0e1ea4258beae7a5
36,205
[ -1 ]
36,206
example-2.lisp
lisp-mirror_gendl/documentation/training/legacy/gdl/source/example-2.lisp
;; ;; Copyright 2002, 2009, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-tutorial) (defparameter *example-2* `((:chapter :title "Example 2: Simplified Android Robot") "This chapter describes and shows the complete code for a Simplified Android Robot" (:footnote "The ``Simplified Android Robot'' is a traditional example used for pedagogical purposes in computer graphics, and as far as we know it has its origins in " (:underline "Computer Graphics: Principles and Practice") " by Foley, Feiner, and Van Dam.") (:index "objects!primitive!geometric") " implemented in GDL/GWL. Here we introduce the use of geometric primitive objects, as well as the use of the higher-level " (:texttt (:indexed "application-mixin")) " first introduced in Chapter " (:ref "chap:gwlsyntax") ". We also introduce the concept of the " (:emph (:indexed "view")) ", which allows separation of presentation functions (e.g. for HTML output) from the core object definition." ((:section :title "Main UI Sheet for the Robot") "Figure " (:ref "code:robot-toplevel") " defines the toplevel user interface sheet for the robot. It specifies several " (:texttt ":settable") " computed-slots which the user will end up being able to set through an HTML form. It also specifies the " (:texttt "robot") " child object, whose leaves contain the actual geometry (boxes in this case) of the robot. Figure " (:ref "code:robot-model-inputs") " shows the definition of a " (:emph "view") " which is defined for the " (:texttt "html-format") " output format, and the " (:texttt "robot-assembly") " GDL object. Rather than being associated with a single type as with normal GDL objects, views are associated with " (:emph "two") " types -- an output format and a normal GDL object type. The " (:texttt ":output-functions") " defined within the view will therefore be associated with the " (:emph "combination") " of the given output-format and the given GDL object type. In this case, we are specifying the " (:texttt (:indexed "model-inputs")) " " (:texttt ":output-function") " to be applied to the combination of the " (:texttt "html-format") " output-format and the " (:texttt "robot-assembly") " GDL object type. The " (:texttt "application-mixin") " contains a default (essentially blank) " (:texttt "model-inputs") " function, and here we are overriding it to do something specific, namely to display html input fields for the slots in our " (:texttt "robot-assembly") " which we wish the user to be able to alter through a form. By default, the " (:texttt "application-mixin") " will display the output from the " (:texttt "model-inputs") " function in the upper-right area of the user interface sheet, as seen in Figure " (:ref "fig:robot") ". These input fields are automatically contained inside an appropriate HTML form entity - when using " (:texttt "application-mixin") ", there is no need for application-level code to generate the HTML form tag or the " (:texttt (:indexed ":respondant")) " or " (:texttt (:indexed ":bashee")) " hidden fields described in Chapter " (:ref "chap:gwlsyntax") " with plain " (:texttt (:indexed "base-html-sheet")) "." ((:boxed-figure :caption "UI Sheet for Robot" :label "code:robot-toplevel") (:verbatim " (define-object robot-assembly (application-mixin) :computed-slots ((width 5 :settable) (length 2 :settable) (height 10 :settable) (head-angle 0 :settable) (body-angle 0 :settable) (arm-angle-right 0 :settable) (arm-angle-left 0 :settable) (pincer-distance-right (to-single-float (number-round (* .15 3/5 (the width)) 3)) :settable) (pincer-distance-left (to-single-float (number-round (* .15 3/5 (the width)) 3)) :settable) (image-format (the view-object image-format)) (strings-for-display \"Robot Assembly\") (ui-display-list-objects (the robot))) :objects ((robot :type 'robot :pass-down (:head-angle :body-angle :arm-angle-right :arm-angle-left :pincer-distance-right :pincer-distance-left)))) ")) ((:boxed-figure :caption "Inputs Section for UI Sheet" :label "code:robot-model-inputs") (:small (:verbatim " (define-view (html-format robot-assembly)() :output-functions ((model-inputs () (html ((:table :cellpadding 0) (:tr ((:td :colspan 2) (:b \"Dimensions:\"))) (dolist (slot (list :width :length :height)) (html (:tr ((:td :bgcolor :yellow) (:princ (string-capitalize slot))) (:td ((:input :type :string :name slot :size 5 :value (format nil \"~a\" (the (evaluate slot))))))))) (:tr ((:td :colspan 2) :br)) (:tr ((:td :colspan 2) (:b \"Angles:\"))) (dolist (angle '((\"Head\" :head-angle)(\"Body\" :body-angle) (\"Left Arm\" :arm-angle-left) (\"Right Arm\" :arm-angle-right))) (html (:tr ((:td :bgcolor :yellow) (:princ (first angle))) (:td ((:input :type :string :name (second angle) :size 5 :value (format nil \"~a\" (the (evaluate (second angle)))))))))) (:tr ((:td :colspan 2) :br)) (:tr ((:td :colspan 2) (:b \"Grip Opening:\"))) (dolist (side (list :left :right)) (html (:tr ((:td :bgcolor :yellow) (:princ (string-capitalize side))) (:td ((:input :type :string :name (format nil \"pincer-distance-~a\" side) :size 5 :value (the (evaluate (make-keyword (format nil \"pincer-distance-~a\" side)))))))))) (:tr ((:td :colspan 2) :br)) (:tr ((:td :colspan 2 :align :center) ((:input :type :submit :value \" OK \" :name :refresh))))))))) "))) ((:image-figure :image-file "robot.png" :caption "Default Robot" :label "fig:robot"))) ((:section :title "Robot Geometry") "The actual robot is made up of two child objects, its " (:texttt "base") " and its " (:texttt "body") ", as shown in Figure " (:ref "code:robot-geometry-toplevel") ". Figure " (:ref "code:robot-body") " shows the definition of the body, and " (:ref "code:robot-base") " shows the definition of the base. The body is made up of a torso (a box), a head (a box), and two arms, whose definition is shown in Figure " (:ref "code:robot-arm") ". The " (:texttt ":settable") " :computed-slots from the toplevel UI sheet come into the " (:texttt "robot") " as input-slots. These serve as parameters for the rest of the robot hierarchy. The positioning and orientation of each child object are specified by passing " (:texttt (:indexed ":center")) " and " (:texttt (:indexed ":orientation")) " into the child part:" ((:list :style :description) ((:item :word ":center") "is given as a 3D point, and causes the child object to treat this point as its center.") ((:item :word ":orientation") "is given as a 3-by-3 rotational transformation matrix, and causes the child object to adjust its six " (:texttt (:indexed "face-normal-vector")) "s accordingly. As with this example, this transformation matrix is usually created using the " (:texttt (:indexed "alignment")) " function, which allows you to align up to three faces of the child object with up to three given vectors. The first vector will be taken exactly, and the second and third vectors will be taken for their orthogonal components to the previous ones.")) ((:boxed-figure :caption "Toplevel of Robot Geometry" :label "code:robot-geometry-toplevel") (:small (:verbatim " (define-object robot (base-object) :input-slots (head-angle body-angle arm-angle-right arm-angle-left pincer-distance-right pincer-distance-left) :computed-slots ((display-controls (list :color :green-lime))) :objects ((base :type 'robot-base :height (* (the :height) 0.4) :width (* (the :width) 0.2) :length (* (the :length) 0.2) :center (translate (the :center) :down (* (the :height) 0.3))) (body :type 'robot-body :height (* (the :height) 0.6) :center (translate (the :center) :up (* (the :height) 0.2)) :orientation (alignment :right (rotate-vector-d (the (:face-normal-vector :right)) (the :body-angle) (the (:face-normal-vector :top)))) :pass-down (:head-angle :arm-angle-right :arm-angle-left :pincer-distance-left :pincer-distance-right)))) "))) ((:boxed-figure :caption "Robot Body" :label "code:robot-body") (:small (:verbatim " (define-object robot-body (base-object) :input-slots (head-angle arm-angle-left arm-angle-right pincer-distance-left pincer-distance-right (shoulder-height (* (the :torso :height) 0.1))) :computed-slots ((display-controls (list :color :blue-steel-light))) :objects ((torso :type 'box :height (* (the :height) 0.85) :width (* (the :width) 0.7) :center (translate (the :center) :down (- (half (the :height)) (half (the-child :height))))) (head :type 'box :display-controls (list :color :magenta) :height (- (the :height) (the :torso :height)) :width (* (the :width) 0.25) :length (half (the :length)) :center (translate (the :center) :up (- (half (the :height)) (half (the-child :height)))) :orientation (alignment :right (rotate-vector-d (the (:face-normal-vector :right)) (the :head-angle) (the (:face-normal-vector :top))))) (arms :type 'robot-arm :sequence (:size 2) :side (ecase (the-child :index) (0 :left) (1 :right)) :width (half (- (the :width) (the :torso :width))) :length (/ (the :length) 3) :height (- (the :torso :height) (twice (the :shoulder-height))) :center (translate-along-vector (the-child :shoulder-point) (the-child (:face-normal-vector :bottom)) (half (the-child :height))) :orientation (alignment :bottom (rotate-vector-d (the (:face-normal-vector :bottom)) (the-child :angle) (the (:face-normal-vector :left))) :right (the (:face-normal-vector :right))) :shoulder-point (translate (the :torso (:edge-center :top (the-child :side))) (the-child :side) (half (the-child :width)) :down (the :shoulder-height)) :angle (ecase (the-child :side) (:left (the :arm-angle-left)) (:right (the :arm-angle-right))) :pincer-distance (ecase (the-child :side) (:left (the :pincer-distance-left)) (:right (the :pincer-distance-right)))))) "))) ((:boxed-figure :caption "Robot Arm" :label "code:robot-arm") (:verbatim " (define-object robot-arm (base-object) :input-slots (side shoulder-point angle pincer-distance) :computed-slots ((display-controls (list :color :blue))) :objects ((arm :type 'box) (thumb :type 'box :display-controls (list :color :red) :width (the :hand :width) :height (the :hand :height) :length (the :hand :length) :center (translate (the :hand :center) (the :side) (the :pincer-distance))) (hand :type 'box :display-controls (list :color :green) :center (translate (the :center) :down (+ (half (the :height)) (half (the-child :height))) (the :side) (- (- (half (the :width)) (half (the-child :width))))) :height (* (the :height) 0.15) :width (* (the :width) 0.2) :length (half (the :length))))) ")) ((:boxed-figure :caption "Robot Base" :label "code:robot-base") (:verbatim " (define-object robot-base (base-object) :objects ((leg :type 'box :height (* 0.9 (the :height)) :center (translate (the :center) :up (- (half (the :height)) (half (the-child :height))))) (foot :type 'box :height (* 0.1 (the :height)) :width (twice (twice (the :width))) :length (twice (twice (twice (the :length)))) :center (translate (the :center) :down (- (half (the :height)) (half (the-child :height))))))) "))) ((:section :title "Using the App") "Figures " (:ref "fig:robot-front") " and " (:ref "fig:robot-swing") " show some examples of a user having interacted with the application, resulting in a specified standard 3D view of the robot or the robot's body parts rotated to specified angles. Note also the extra hyperlinks at the upper-left in Figure " (:ref "fig:robot-front") ", which are a result of the GDL/GWL session being in " (:emph (:indexed "development mode")) ". Development mode can be entered as follows:" (:index "gwl:*developing?*") (:verbatim "(setq gwl:*developing?* t)") "The three standard links provided by development mode are as follows:" ((:list :style :description) ((:item :word "Update!") "will essentially re-instantiate the object hierarchy from the current object downward, taking into account any new or altered definitions you have compiled since the objects were last demanded. However, any " (:texttt ":settable") " slots which have been altered will retain their values to the extent feasible.") ((:item :word "Full Update!") "will perform and Update all the way from the root object.") ((:item :word "Break") "will cause a Common Lisp break level to be entered, with the parameter " (:texttt "self") " set to the object instance corresponding to the current web page.") ((:item :word (:indexed "TaTu")) "will respond with the development view of the object, as described in the file " (:texttt "tatu.txt") ".")) ((:image-figure :image-file "robot-front.png" :caption "Front View of Robot" :label "fig:robot-front")) ((:image-figure :image-file "robot-swing.png" :caption "Robot with some non-Default Angles" :label "fig:robot-swing")))))
16,838
Common Lisp
.lisp
389
33.251928
128
0.572794
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
627f7ba8d6889f763310a8da118e3221ae3b1b3cbd792e6974d5c46a071742a6
36,206
[ -1 ]
36,207
examples.lisp
lisp-mirror_gendl/documentation/training/legacy/gdl/source/examples.lisp
;; ;; Copyright 2002, 2009, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-tutorial) (define-object assembly-1 (base-object) :input-slots ((account-data-file "~/genworks/gwl-apps/ledger/data/accounts.lisp") (transaction-data-file "~/genworks/gwl-apps/ledger/data/transactions.lisp")) :computed-slots ((account-data (let (result) (with-open-file (in (the account-data-file)) (do ((account (read in nil nil) (read in nil nil))) ((null account) (nreverse result)) (push account result))))) (transaction-data (let (result) (with-open-file (in (the transaction-data-file)) (do ((transaction (read in nil nil) (read in nil nil))) ((null transaction) (nreverse result)) (push transaction result))))) (account-indices (mapcar #'(lambda(account) (the-object account index)) (list-elements (the accounts)))) (transaction-indices (mapcar #'(lambda(transaction) (the-object transaction index)) (list-elements (the transactions)))) (net-worth (let ((result 0)) (dolist (account (list-elements (the accounts)) result) (when (eql (make-keyword (the-object account account-class)) :asset/liability) (incf result (the-object account current-balance)))))) (profit (let ((result 0)) (dolist (account (list-elements (the accounts)) result) (when (eql (make-keyword (the-object account account-class)) :income/expense) (decf result (the-object account current-balance)))))) (balances-hash-table (let ((ht (make-hash-table))) (dolist (account (list-elements (the accounts))) (setf (gethash (the-object account index) ht) (the-object account beginning-balance))) (dolist (transaction (list-elements (the transactions)) ht) (decf (gethash (the-object transaction from-account) ht) (the-object transaction amount)) (incf (gethash (the-object transaction to-account) ht) (the-object transaction amount)))))))
3,456
Common Lisp
.lisp
63
39.761905
81
0.564583
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
103e1fa2bf47ad6440627cbc45da4a41cd70c15339b6f7f9597c0187764fc427
36,207
[ -1 ]
36,208
gdl-syntax.lisp
lisp-mirror_gendl/documentation/training/legacy/gdl/source/gdl-syntax.lisp
;; ;; Copyright 2002, 2009, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-tutorial) (defparameter *gdl-syntax* `((:chapter :title "GDL Syntax") ((:section :title "Define-Object") (:index "objects!defining") (:emph (:indexed "Define-object")) " is the basic macro for defining objects in GDL. An object definition maps directly into a Lisp (CLOS) class definition. The " (:texttt "define-object") " macro takes three basic arguments:" ((:list :style :itemize) (:item "a " (:emph "name") ", which is a symbol;") (:item "a " (:emph (:indexed "mixin-list")) ", which is a list of symbols naming other objects from which the current object will inherit characteristics;") (:item "a " (:emph (:indexed "specification-plist")) ", which is spliced in (i.e.\\ doesn't have its own surrounding parentheses) after the mixin-list, and describes the object model by specifying properties of the object (messages, contained objects, etc.) The specification-plist typically makes up the bulk of the object definition.")) " Here are descriptions of the most common keywords making up the specification-plist:" ((:list :style :description) ((:item :word (:indexed "input-slots")) "specify information to be passed into the object instance when it is created.") ((:item :word (:indexed "computed-slots")) "are really cached methods, with expressions to compute and return a value.") ((:item :word (:indexed "objects")) "specify other instances to be ``contained'' within this instance.") ((:item :word (:indexed "functions")) "are (uncached) functions ``of'' the object, i.e.\\ they are actually methods which discriminate on their first argument, which is the object instance upon which they are operating. GDL functions can also take other non-specialized arguments, just like a normal CL function.")) "Figure " (:ref "fig:object-hello") " shows a simple example, which contains two input-slots, " (:texttt "first-name") " and " (:texttt "last-name") ", and a single computed-slot, " (:texttt "greeting") "." ((:boxed-figure :caption "Example of Simple Object Definition" :label "fig:object-hello") (:verbatim " (define-object hello () :input-slots (first-name last-name) :computed-slots ((greeting (format nil \"Hello, ~a ~a!!\" (the first-name) (the last-name))))) ")) "As you can see, a GDL Object is analogous in some ways to a " (:texttt "defun") ", where the input-slots are like arguments to the function, and the computed-slots are like return-values. But seen another way, each attribute in a GDL object is like a function in its own right. The referencing macro " (:texttt (:indexed "the")) " shadows CL's " (:texttt "the") " (which is a seldom-used type declaration operator). " (:texttt "The") " in GDL is a macro which is used to reference the value of other messages within the same object or within contained objects. In the above example, we are using " (:texttt "the") " to refer to the values of the messages (input-slots) named " (:texttt "first-name") " and " (:texttt "last-name") ". Note that messages used with " (:texttt "the") " are given as symbols. These symbols are unaffected by the current Lisp " (:texttt "*package*") ", so they can be specified either as plain unquoted symbols or as keyword symbols (i.e.\\ preceded by a colon), and the " (:texttt "the") " macro will process them appropriately.") ((:section :title "Making Instances and Sending Messages") "Once we have defined an object such as the example above, we can use the constructor function " (:texttt (:indexed "make-object")) " in order to create an " (:emph "instance") " of it. This function is very similar to the CLOS " (:texttt (:indexed "make-instance")) " function. Here we create an instance of " (:texttt "hello") " with specified values for " (:texttt "first-name") " and " (:texttt "last-name") " (the required input-slots), and assign this instance as the value of the symbol " (:texttt "my-instance") ":" (:verbatim " GDL-USER(16): (setq my-instance (make-object 'hello :first-name \"John\" :last-name \"Doe\")) #<HELLO @ #x218f39c2>") "As you can see, keyword symbols are used to ``tag'' the input values, and the return value is an instance of class " (:texttt "hello") ". Now that we have an instance, we can use the macro " (:texttt (:indexed "the-object")) " to send messages to this instance:" (:verbatim " GDL-USER(17): (the-object my-instance greeting) \"Hello, John Doe!!\"") (:texttt "The-object") " is similar to " (:texttt "the") ", but as its first argument it takes an expression which evaluates to an object instance. " (:texttt "The") ", by contrast, assumes that the object instance is the lexical variable " (:texttt (:indexed "self")) ", which is automatically set within the lexical context of a " (:texttt "define-object") ". Like " (:texttt "the") ", " (:texttt "the-object") " evaluates all but the first of its arguments as package-immune symbols, so although keyword symbols may be used, this is not a requirement, and plain, unquoted symbols will work just fine. For convenience, you can also set " (:texttt "self") " manually at the CL Command Prompt, and use " (:texttt "the") " instead of " (:texttt "the-object") " for referencing:" (:verbatim " GDL-USER(18): (setq self (make-object 'hello :first-name \"John\" :last-name \"Doe\")) #<HELLO @ #x218f406a> GDL-USER(19): (the greeting) \"Hello, John Doe!!\"") "In actual fact, " (:texttt "(the ...)") " simply expands into " (:texttt "(the-object self ...)") ".") ((:section :title "Objects") (:index "objects") (:index "containment!object") (:index "objects!child") (:index "objects!contained") "The " (:texttt ":objects") " keyword specifies a list of ``contained'' instances, where each instance is considered to be a ``child'' object of the current object. Each child object is of a specified type, which itself must be defined with " (:texttt "define-object") " before the child object can be instantiated. Inputs to each instance are specified as a plist of keywords and value expressions, spliced in after the object's name and type specification. These inputs must match the inputs protocol (i.e.\\ the input-slots) of the object being instantiated. Figure " (:ref "fig:object-city") " shows an example of an object which contains some child objects." ((:boxed-figure :caption "Object Containing Child Objects" :label "fig:object-city") (:verbatim " (define-object city () :computed-slots ((total-water-usage (+ (the hotel water-usage) (the bank water-usage)))) :objects ((hotel :type 'hotel :size :large) (bank :type 'bank :size :medium))) ")) "In this example, " (:texttt "hotel") " and " (:texttt "bank") " are presumed to be already (or soon to be) defined as objects themselves, which each answer the " (:texttt "water-usage") " message. The " (:emph (:indexed "reference chains")) ":" (:verbatim "(the hotel water-usage)") " and " (:verbatim "(the bank water-usage)") " provide the mechanism to access messages within the child object instances. These child objects become instantiated " (:emph "on demand") ", meaning that the first time these instances or any of their messages are referenced, the actual instance will be created " (:emph "and") " cached for future reference.") ((:boxed-figure :caption "Sample Data and Object Definition to Contain U.S. Presidents" :label "fig:object-presidents-container") (:verbatim " (defparameter *presidents-data* '((:name \"Carter\" :term 1976) (:name \"Reagan\" :term 1980) (:name \"Bush\" :term 1988) (:name \"Clinton\" :term 1992))) (define-object presidents-container () :input-slots ((data *presidents-data*)) :objects ((presidents :type 'president :sequence (:size (length (the data))) :name (getf (nth (the-child index) (the data)) :name) :term (getf (nth (the-child index) (the data)) :term)))) ")) ((:section :title "Sequences of Objects and Input-slots with a Default Expression") "Objects may be " (:emph "sequenced") (:index "Objects!sequenced") (:index "sequences") (:index "object sequences") ", to specify, in effect, an array or list of object instances. The most common type of sequence is called a " (:emph "fixed size") " sequence. See Figure " (:ref "fig:object-presidents-container") " for an example of an object which contains a sequenced set of instances representing U.S. presidents. Each member of the sequenced set is fed inputs from a list of plists, which simulates a relational database table (essentially a ``list of rows''). Note the following from this example:" ((:list :style :itemize) (:item "In order to sequence an object, the input keyword " (:texttt ":sequence") " is added, with a list consisting of the keyword " (:texttt (:indexed ":size")) " followed by an expression which must evaluate to a number.") (:item "In the input-slots, " (:texttt "data") " is specified together with a default expression. Used this way, input-slots function as a hybrid of computed-slots and input-slots, allowing a " (:emph "default expression") " as with computed-slots, but allowing a value to be passed in on instantiation or from the parent, as with an input-slot which has no default expression. A passed-in value will override the default expression."))) ((:section :title "Summary") "This GDL syntax overview has been kept purposely brief, covering the fundamentals of the language in a dense manner. On one hand, it is not meant to be a comprehensive language reference; on the other hand, do not be concerned if you are still unsure about some of the terminology. The upcoming examples will revisit and further expand many of the topics covered here, and at some point a coherent picture should begin to emerge. At that point it will be like riding a bicycle, and there will be no going back. ")))
12,253
Common Lisp
.lisp
281
36.177936
125
0.637752
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ce1f9ac2336650ce093b63d62e80791840314a0d7ac8e757b14772f1914b1d98
36,208
[ -1 ]
36,209
gwl-syntax.lisp
lisp-mirror_gendl/documentation/training/legacy/gdl/source/gwl-syntax.lisp
;; ;; Copyright 2002, 2009, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-tutorial) (defparameter *gwl-syntax* `((:chapter :title "GWL Syntax") (:index "web user interface!creating") (:index "HTTP") (:index "HTML") "GWL (Generative Web Language) consists essentially of a set of mixins and a few functions which provide a convenient mechanism to present KB objects defined in GDL through a standard HTTP/HTML web user interface. GWL ships as a standard component of the commercial GDL product, and is available on the GDL Trial Edition CD as well. GWL is designed to operate in conjunction with AllegroServe" (:index "AllegroServe") (:index "htmlgen") (:footnote "AllegroServe is an open-source webserver from Franz Inc, available at http://opensource.franz.com") " and its companion HTML generating facility, htmlgen. This chapter describes basic GWL usage and syntax. It assumes familiarity with the underlying base language, GDL, covered in the previous chapter." ((:section :title "Testing your GWL Installation") "After you have installed according to " (:texttt "install.htm") ":" ((:list :style :enumerate) (:item "Make sure you have started AllegroServe with:" (:verbatim "(net.aserve:start :port 9000)") "(or any port of your choice)") (:item "In any standard web browser, go to:" (:verbatim "http://<hostname>:<port>/demos/robot") "e.g.: " (:verbatim "http://localhost:9000/demos/robot"))) "You should see a page with a simple robot assembly made from boxes. If the robot shows up as well as the orange graphical \"compass\" below the graphics viewport, your installation is likely working correctly.") ((:section :title "GWL:Define-Package") "The macro " (:texttt "gwl:define-package") " is provided for setting up new working GWL packages. Example:" (:verbatim "(gwl:define-package :gwl-user)") "The " (:texttt ":gwl-user") " package is an empty, pre-defined package for your use if you do not wish to make a new package just for scratch work. For real projects it is recommended that you make and work in your own GWL package.") ((:section :title "Basic Usage") "To present a GDL object instance as a web page requires two simple steps:" ((:list :style :enumerate) (:item "mix in " (:texttt (:indexed "base-html-sheet")) " or a subclass thereof") (:item "define a function in the object called " (:texttt (:indexed "write-html-sheet")))) "The " (:texttt "write-html-sheet") " function should typically make use of the htmlgen " (:texttt "html") " macro. It does not need to take any arguments. Please see the htmlgen documentation (at " (:texttt "http://opensource.franz.com") ", with the AllegroServe distribution, or in " (:texttt "<gdl-home>/doc/aserve/") ") for full details on the use of htmlgen. The code for a simple example object with its " (:texttt "write-html-sheet") " presentation function is shown in Figure " (:ref "code:basic-usage") ". This example contains two optional input slots with values for Name and Term of a president, and creates a simple HTML table displaying this information. As outlined above, in order to make an instance and display this object through a web browser, you would visit the URI:" (:verbatim "http://<host>:<port>/make?object=gwl-user::president") ((:boxed-figure :caption "Basic Usage" :label "code:basic-usage") (:verbatim " (define-object president (base-html-sheet) :input-slots ((name \"Carter\") (term 1976)) :functions ((write-html-sheet () (html (:html (:head (:title (format nil \"Info on President: ~a\" (the name)))) (:body (:table (:tr (:td \"Name\") (:td \"Term\")) (:tr (:td (:princ (the name))) (:td (:princ (the term))))))))))) "))) ((:section :title "Page Linking") "Creating hypertext links to other pages in the page hierarchy is usually accomplished with the built-in GDL function of " (:texttt "base-html-sheet") " called " (:texttt "write-self-link") ". This GDL function, when called on a particular page instance, will write a hypertext link referring to that page instance. These hypertext links are published by AllegroServe ``on the fly'' (as a side-effect of being demanded), and are made up from the unique root-path of the target object, as well as an " (:indexed "instance-id") " which identifies the particular object instance which is the ``root'' of the relevant page hierarchy. This is necessary because GWL maintains a table of root-level instances. Each root-level instance will usually correspond to one \"user\" or session. However, in general, there can be a many-to-many relationship between user sessions and root-level instances. The instance-id is generated randomly. On a publicly-accessible website, the maximum instance-id should be set to a very large number to decrease the likelihood of a malicious visitor being able to ``guess'' the instance-id of another user. The maximum is set with the parameter " (:texttt (:indexed "gwl:*max-id-value*")) ". Figures " (:ref "code:page-linking") " and " (:ref "code:link-target") " show the code for making a page with a list of links to pages representing individual U.S. presidents, resulting in a web page which should resemble Figure " (:ref "fig:presidents-container") ". Note the call to the " (:texttt "write-self-link") " function inside the " (:texttt "dolist") " in Figure " (:ref "code:page-linking") ". This results in an HTML list item being generated with a hyperlink for each ``president'' child object. Note also the use of the " (:texttt (:indexed "write-back-link")) " function in " (:texttt "presidents-display") ". This will generate a link back to the " (:texttt (:indexed "return-object")) " of the object, which defaults to the object's " (:texttt "parent") "." ((:boxed-figure :caption "Making a List of Links" :label "code:page-linking") (:verbatim " (define-object presidents-container (base-html-sheet) :input-slots ((data '((:last-name \"Carter\" :term 1976) (:last-name \"Clinton\" :term 1992)))) :objects ((presidents :type 'president-display :sequence (:size (length (the data))) :last-name (getf (nth (the-child index) (the data)) :last-name) :term (getf (nth (the-child index) (the data)) :term))) :functions ((write-html-sheet () (html (:html (:head (:title \"Links to Presidents\")) (:body (:h1 \"Links to the Presidents\") (:ol (dolist (president (list-elements (the presidents))) (html (:li (the-object president (write-self-link)))))))))))) ")) ((:boxed-figure :caption "Link Target" :label "code:link-target") (:verbatim " (define-object president-display (base-html-sheet) :input-slots (last-name term) :computed-slots ((strings-for-display (the last-name))) :functions ((write-html-sheet () (html (:html (:head (:title (:princ (the last-name)))) (:body (:h1 (:princ (the last-name))) \"Term: \" (:princ (the term)) (:p (the (write-back-link))))))))) ")) ((:image-figure :image-file "presidents-container.png" :caption "Presidents Container Page with Links" :label "fig:presidents-container")) ) ((:section :title "Form Handling") (:index "form handling") "Forms are generated using the GWL macro" (:texttt "with-html-form") ". You wrap this macro around the HTMLgen code which creates the contents of the form:" (:verbatim " (with-html-form () ;; the body of your form goes here )") "The above code snippet would be included in a " (:texttt "write-html-sheet") "function of a page definition. By default, the same object which generates the form will also respond to the form, and is also the object which will have its settable slots modified based on form fields (i.e. html ``inputs'') of the same name. You can override the default by specifying a " (:texttt "bashee") " and/or " (:texttt "respondent") "as slots in the requestor object (i.e. the object which is generating the form), for example:" (:verbatim " :computed-slots ((respondent (the some-other-object)) (bashee (the yet-another-object))) ") "Any " (:texttt ":settable") " computed-slots in the object may be specified as input values (i.e.\\ with " (:texttt ":input") " tags) in the form. GWL will automatically infer their types and do appropriate conversion. If the type of a slot can vary, it is best to make its default be a string, then have your application read from the string (with the " (:texttt (:indexed "read-safe-string")) " function). Note that only those input values which have actually changed (according to " (:texttt "equalp") " ) will be set into the corresponding computed-slot upon form submission. Ones which remain the same will be left alone (to avoid unnecessary dependency updating in the model). Any " (:texttt ":input") " values in the form whose name does not match one of the " (:texttt ":settable") " computed-slots in the object will still be collected, but rather than being set into its own named slot, it will be returned as part of the special " (:texttt "query-plist") " message when the response page's " (:texttt "write-html-sheet") " method is invoked. " (:texttt "Query-plist") " is a plist containing keywords representing the form field names, and values which will be strings representing the submitted values. If you want to do additional processing, the following functions are provided for " (:texttt "base-html-sheet") ":" ((:list :style :description) ((:item :word "before-set!") "This is invoked before the ``bashee'' is modified with any new form values.") ((:item :word "after-set!") "This is invoked after the ``bashee'' is modified with any new form values.") ((:item :word "before-present!") "This is invoked after the ``bashee'' is modified with any new form values, but before the page content is returned to the web client.") ((:item :word "after-present!") "This is invoked after the page content is returned to the web client.")) " By default, these functions are empty, but you can override them to do whatever extra processing you wish. Figure " (:ref "code:hello-form") " shows an object which both generates and responds to a simple form, with the corresponding web page shown in Figure " (:ref "fig:hello-form") ". The form allows the user to type a name to override the default ``Jack,'' and reflects the submitted name in the form page upon response. To instantiate this object in a web browser, you would visit the URI:" (:verbatim "http://<host>:<port>/make?object=gwl-user::hello-form") ((:boxed-figure :caption "Hello Form" :label "code:hello-form") (:verbatim " (define-object hello-form (base-html-sheet) :computed-slots ((username \"Jack\" :settable)) :functions ((write-html-sheet () (html (:html (:head (:title \"Sample Form\")) (:body (:p \"Hello there, \" (:princ (the username)) \"!\") (:p (with-html-form () ((:input :type :text :name :username :value (the username))) ((:input :type :submit :name :submit :value \" Change Name! \")))))))))) ")) ((:image-figure :image-file "hello-form.png" :caption "Hello Form" :label "fig:hello-form"))) ((:section :title "Publishing URIs for GWL Objects") (:index "publishing!of GWL URIs") "You can publish a URI for a given object, to avoid having to type the ``make?'' expression, using the AllegroServe " (:texttt "publish") " function and the GWL " (:texttt (:indexed "gwl-make-object")) " function, as per the following example:" (:verbatim " (publish :path \"/demos/bus\" :function #'(lambda(req ent) (gwl-make-object req ent \"bus:assembly\")))") "In this example, the ``bus'' object would now be instantiated simply by visiting the URI:" (:verbatim "http://<host>:<port>/bus")) ((:section :title "Higher-level Apps and Graphics") "GDL/GWL also has the ability to generate and display standard wireframe geometric entities. The complete list of currently available primitive geometric objects is available in the GDL documentation set. Currently the only documented way to display geometry in a GWL application is by using the higher-level mixin " (:texttt (:indexed "application-mixin")) ". Two complete examples of the use of this mixin, the Robot and the School Bus, are given in Chapters " (:ref "chap:example2:simplifiedandroidrobot") " and " (:ref "chap:example3:schoolbus") ". Here we will just touch on the basics of how to use this mixin." ((:list :style :enumerate) (:item "Instead of " (:texttt "base-html-sheet") ", mix in " (:texttt "application-mixin") " into the object definition you wish to publish via the web.") (:item "Collect the objects whose leaves you wish to display as geometry in a computed-slot named" (:texttt (:indexed "ui-display-list-objects")) ".")) "Following the above steps will result in a page with a default user interface which will display your graphics in the center. This page, and each of its components, are highly customizable, and we will look at some of the available customizations in the examples in Chapters " (:ref "chap:example2:simplifiedandroidrobot") " and " (:ref "chap:example3:schoolbus") ".")))
15,870
Common Lisp
.lisp
365
36.054795
106
0.643711
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
9777e28cd32fe0956f9aabf3145a23f7e581da25a172d648a0406db1b338f499
36,209
[ -1 ]
36,210
example-3.lisp
lisp-mirror_gendl/documentation/training/legacy/gdl/source/example-3.lisp
;; ;; Copyright 2002, 2009, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-tutorial) (defparameter *example-3* `((:chapter :title "Example 3: School Bus") "In this chapter we leave you with another example of a geometric GDL/GWL application, heavy on code examples, with a bit of explanation sprinkled in between. This School Bus example introduces the use of the " (:texttt (:indexed "node-mixin")) " primitive object, which is similar to " (:texttt (:indexed "application-mixin")) " which we met in the last chapter. But " (:texttt "node-mixin") " is used to " (:emph "contain") " other instances of either " (:texttt "node-mixin") " or " (:texttt "application-mixin") ", and automatically collects up any " (:texttt (:indexed "ui-display-list-objects")) " or rule objects (i.e.\\ objects of type " (:texttt (:indexed "gwl-rule-object")) ") from its descendants." ((:section :title "Toplevel Assembly") "Figure " (:ref "code:school-bus") " defines the toplevel assembly consisting of a chassis, body, and interior. The toplevel mixes in " (:texttt "node-mixin") ", and the chassis, body, and interior each mix in " (:texttt "application-mixin") ". This results in a high-level user-visible hierarchy, shown as the ``Assembly Tree'' in the lower-left of Figure " (:ref "fig:school-bus") ". Note that there is no need to specify a " (:texttt "ui-display-list-objects") " slot in the " (:texttt "assembly") ". This is because " (:texttt "node-mixin") " automatically defines this slot, which appends together the " (:texttt "ui-display-list-objects") " from any child objects of appropriate types. Three toplevel " (:texttt ":settable") " computed-slots are also specified, affecting the overall dimensions of the vehicle. Figure " (:ref "code:school-bus-model-inputs") " defines the " (:texttt "model-inputs") " for the toplevel, corresponding to the three " (:texttt ":settable") " computed-slots in the " (:texttt "assembly") ". The complete code for the School Bus example is provided on the GDL (and Trial Edition) CD; in this tutorial we provide only the major portion of the interior. The chassis and body are defined similarly, although the chassis in particular contains several interesting examples, which are beyond the scope of this tutorial, of solving somewhat ``heavier'' engineering problems with GDL/GWL." ((:boxed-figure :caption "Toplevel Assembly for School Bus" :label "code:school-bus") (:verbatim " (define-object assembly (node-mixin) :computed-slots ((frame-datum (let ((datum (read-safe-string (string-append \"(\" (the frame-datum-m) \")\")))) (translate (the center) :right (first datum) :rear (second datum) :top (third datum)))) (strings-for-display \"School Bus\") (wheelbase 300 :settable) (track 96 :settable) (height 80 :settable) (frame-datum-m \"2000 500 0\" :settable)) :objects ((chassis :type 'chassis :pass-down (:wheelbase :track) :datum (the frame-datum) :height 20) (body :type 'body :pass-down (:wheelbase :track) :frame-width (the chassis frame-width) :frame-overhang (- (the-child front-overhang) (the chassis front-overhang)) :firewall-base (translate (the frame-datum) :up (half (the chassis frame-height)) :right (- (the-child cab-width) (the-child frame-overhang)))) (interior :type 'interior :firewall-base (the body firewall-base) :width (- (the body width) (the body cab-width)) :length (the body length) :height (the body height)))) ")) ((:boxed-figure :caption "HTML format View of Model Inputs for School Bus Toplevel" :label "code:school-bus-model-inputs") (:verbatim " (define-view (html-format assembly) nil :output-functions ((model-inputs nil (html (:p (:table (:tr ((:td :bgcolor :yellow) \"Wheelbase\") (:td ((:input :type :text :size 5 :name :wheelbase :value (the :wheelbase))))) (:tr ((:td :bgcolor :yellow) \"Track\") (:td ((:input :type :text :size 5 :name :track :value (the :track))))) (:tr ((:td :bgcolor :yellow) \"Height\") (:td ((:input :type :text :size 5 :name :height :value (the :height))))))) (:p ((:input :type :submit :name :submit :value \" OK \"))))))) ")) ((:image-figure :image-file "school-bus.png" :caption "Toplevel Sheet of School Bus App" :label "fig:school-bus"))) ((:section :title "Interior of School Bus") "Figures " (:ref "code:school-bus-interior") " and " (:ref "code:school-bus-seating-section") " define the major components making up the interior of the bus, which for our current purposes consists of the bench seats and a few rules regarding their spacing. In particular, Figure " (:ref "code:school-bus-seating-section") " defines the " (:texttt "seating-section") " which contains the two actual columns of bench seats. This object also contains two " (:emph "rule objects") " which compute certain key pieces of information:" ((:list :style :description) ((:item :word "inter-seat-spacing-computation") "computes the exact spacing from the front of one seat to the front of the next, given the available cabin width (i.e.\\ coach length), the maximumm allowed recline angle of the seat backs, and the number of rows to be fit into the bus. (The actual seat dimensions are taken from defaults in the seat object definition, not listed here). This spacing value is crucial for two reasons: first, this value is used in order to generate the actual geometric objects that you see in the graphical output. Second, this value is used in the " (:texttt "inter-seat-clearance-check") " to compare with the overall length of one seat, to compute how much is left over to be considered ``legroom.''") (:index "rules!diagnostic") (:index "rules!generative") (:index "rules!violating") (:index "rules!model!tight integration with") (:index "rules") ((:item :word "inter-seat-clearance-check") "is a purely diagnostic rule which uses values from the spacing computation rule in order to compute the effective ``legroom'' between seats. This legroom is compared with the rule's specified " (:texttt "value") " (in this case representing the allowed minimum value), to determine whether the rule has violated its condition or not.")) "It is typical in a KB model to have this kind of tight integration between ``rules'' and the model itself --- when an input to the model is changed, any rules and other objects which directly or indirectly depend on that input will automatically re-evaluate themselves. Rules and objects which are not affected by a given change will avoid the computational work of re-evaluating themselves. Maintaining this kind of dependency management in a traditional procedural language environment becomes extremely burdensome on the application developer. In a KB environment, however, this dependency management ``just happens'' as a matter of course." (:index "dependency management") ((:boxed-figure :caption "Interior Assembly Component School Bus" :label "code:school-bus-interior") (:verbatim " (define-object interior (application-mixin) :input-slots (firewall-base length width height) :computed-slots ((ui-display-list-objects (the :sections)) (number-of-rows 10 :settable) (reclined-angle 20 :settable) (max-reclined-angle 30 :settable) (minimum-inter-seat-clearance 7 :settable)) :objects ((sections :type 'seating-section :body-reference-points (list :left (translate (the :firewall-base) :front (half (the :length)) :right (the :width)) :right (translate (the :firewall-base) :rear (half (the :length)) :right (the :width))) :usable-cabin-width (the :width) :pass-down (:number-of-rows :reclined-angle :max-reclined-angle :minimum-inter-seat-clearance)))) ")) ((:boxed-figure :caption "HTML Format Model Inputs of School Bus Interior" :label "code:school-bus-interior-model-inputs") (:verbatim " (define-view (html-format interior) nil :output-functions ((model-inputs nil (html (:p (:table (:tr ((:td :bgcolor :yellow) \"Rows\") (:td ((:input :type :text :size 5 :name :number-of-rows :value (the :number-of-rows))))) (:tr ((:td :bgcolor :yellow) \"Seat Recline\") (:td ((:input :type :text :size 5 :name :reclined-angle :value (the :reclined-angle))))) (:tr ((:td :bgcolor :yellow) \"Max Recline\") (:td ((:input :type :text :size 5 :name :max-reclined-angle :value (the :max-reclined-angle))))) (:tr ((:td :bgcolor :yellow) \"Req'd Clearance\") (:td ((:input :type :text :size 5 :name :minimum-inter-seat-clearance :value (the :minimum-inter-seat-clearance))))))) (:p ((:input :type :submit :name :submit :value \" OK \"))))))) ")) ((:image-figure :image-file "school-bus-interior.png" :caption "Interior of School Bus" :label "fig:school-bus-interior")) ((:boxed-figure :caption "Object Definition for Seating Columns" :label "code:school-bus-seating-section") (:verbatim " (define-object seating-section (base-object) :input-slots (fare-class usable-cabin-width body-reference-points max-reclined-angle number-of-rows minimum-inter-seat-clearance) :objects ((inter-seat-spacing-computation :type 'inter-seat-spacing :pass-down (:max-reclined-angle :usable-cabin-width :number-of-rows)) (inter-seat-clearance-check :type 'inter-seat-clearance-check :inter-seat-spacing (the inter-seat-spacing-computation result) :clearance-extent-typical (the inter-seat-spacing-computation clearance-extent-typical) :value (the minimum-inter-seat-clearance)) (sides :type 'seating-side :fare-class (the fare-class) :sequence (:size 2) :side (ecase (the-child index) (0 :left) (1 :right)) :display-controls (list :color :green) :body-reference-point (getf (the body-reference-points) (the-child side)) :pass-down (:number-of-rows :reclined-angle) :inter-seat-spacing (the inter-seat-spacing-computation result) :x-max-typical (the inter-seat-spacing-computation x-max-typical) :x-vector (the (face-normal-vector :right))))) ")) ((:image-figure :image-file "school-bus-interior-front.png" :caption "Front View of School Bus Interior" :label "fig:school-bus-interior-front"))) :newpage ((:section :title "Causing a Rule Violation") "Figure " (:ref "fig:school-bus-violated") " shows the state of the interior after a user has changed the number of seating rows to eleven, from the default ten. The user has also changed the displayed recline angle of the seat backs to match the maximum allowed value (30 degrees). In this state, the seats have redistributed themselves so that they still are spaced evenly in the available length of the coach. However, this has caused a violation in the legroom, defined as the horizontal distance from the rear-center of one seat back to the front of the seat bottom aft of it. The allowed value for this legroom (``Req'd Clearance'') is 7, and the current legroom value (as computed by the rule object) is now less than this. Therefore we have a violation, and the link to the rule shows up in the ``Violations'' section of the user interface. For a typical example such as this School Bus, one can imagine dozens or hundreds of other rules. Many such rules can be computed based on information we already have in our model, and others will result in the model being augmented incrementally with new information as needed. The main point is that we now have a stable, user-friendly, and readily scalable framework in which to represent and grow our ``knowledge.'' " ((:image-figure :image-file "school-bus-interior-violated.png" :caption "Interior of School Bus with 11 Rows (Legroom Violation)" :label "fig:school-bus-violated")))))
14,722
Common Lisp
.lisp
331
35.483384
93
0.626344
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
42ad84fa978496478be6f05ae928b250fc7d25260ae5daab7168cec7862ad494
36,210
[ -1 ]
36,211
solutions.lisp
lisp-mirror_gendl/documentation/training/g101/examples/source/solutions.lisp
;; ;; Copyright 2002-2011, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (defun dots (num) (dotimes (n num) (princ "."))) (defun dots-r (num) (unless (zerop num) (princ ".") (dots-r (- num 1)))) (defun nth-rest (list num) (if (zerop num) list (rest (nth-rest list (1- num))))) (defun our-nth (num list) (first (nth-rest list num))) (defun our-getf (list key) (when list (if (eql key (first list)) (second list) (our-getf (rest (rest list)) key)))) (defun position-filter (function list) (let ((counter -1) result) (dolist (element list (reverse result)) (when (funcall function (incf counter)) (push element result))))) (defun how-much (n) (cond ((> n 10) "It's a lot") ((= n 10) "It's kind of a lot") (t "It's not a lot"))) (defun greeting (&key (username "Jake") (greeting "how are you?")) (format nil "Hello there ~a, ~a" username greeting)) (defun comment (color) (ecase color (:blue "Blue is okay") (:red "Red is actually her favorite color") (:green "Are you nuts?"))) (let ((hash (make-hash-table))) (defun factorial (n) (or (gethash n hash) (setf (gethash n hash) (if (<= n 1) 1 (* n (factorial (1- n)))))))) (defun sort-names (lists &key (ordering :ascending)) (let ((comparator (ecase ordering ((:ascending :up) #'string-lessp) ((:descending :down) #'string-greaterp)))) (let ((predicate #'(lambda(list1 list2) (funcall comparator (first list1) (first list2))))) (safe-sort lists predicate)))) (defun sort-lists (lists &key (ordering :ascending)) (let ((comparator (ecase ordering ((:ascending :up) #'<) ((:descending :down) #'>)))) (let ((predicate #'(lambda(list1 list2) (funcall comparator (first list1) (first list2))))) (safe-sort lists predicate)))) (defun sort-numbers (numbers &key (ordering :ascending)) (let ((predicate (ecase ordering ((:ascending :up) #'<) (:descending #'>)))) (safe-sort numbers predicate)))
2,854
Common Lisp
.lisp
79
32.21519
70
0.657904
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c12e59fc6a4f87bbf33946e692fe59e1bc12faadeeeadac8ace51bd5c485ca90
36,211
[ -1 ]
36,212
file-io.lisp
lisp-mirror_gendl/documentation/training/g101/examples/source/file-io.lisp
;; ;; Copyright 2002-2011, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (defun file-size (pathname) (with-open-file (in pathname) (do ((line (read-line in nil nil) (read-line in nil nil))) ((null line)(file-position in))))) (defun read-large (pathname starting-at &key from-end?) "List of strings. Returns a list with one string for each line in ascii file, starting from position given by starting-at." (with-open-file (in pathname) (file-position in (if from-end? (- (file-length in) starting-at) starting-at)) (let (result) (do ((line (read-line in nil nil)(read-line in nil nil))) ((null line) (nreverse result)) (push line result)))))
1,471
Common Lisp
.lisp
35
39.942857
79
0.730635
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4543563eb10940e6f96227e51acb552a219c38d4d6b899861f1a18b9b9fb3fd2
36,212
[ -1 ]
36,213
assembly.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/assembly.lisp
;; ;; Copyright 2002-2011, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object assembly (slide-show-node) :input-slots ((title "G101: Common Lisp for GDL Developers") (slide-package (find-package :training-g101)) (audio-base-url "/g101/mp3/") (image-base-url "/g101/images/") (style-url "/g101/style/top.css")) :objects ((introduction :type 'introduction) (welcome :type 'welcome) (lists :type 'lists) (control :type 'control) (functions :type 'functions) (input-output :type 'input-output) (numbers :type 'numbers) (data-structures :type 'data-structures) ;;(macros :type 'macros) (symbols :type 'symbols) (conclusion :type 'conclusion) ))
1,580
Common Lisp
.lisp
41
35.95122
70
0.698039
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
272929034f08539871d9f009d1f83eb1b1aaa4e8b245dd98cfb18088fc0d9c26
36,213
[ -1 ]
36,214
symbols.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/symbols.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object symbols (slide-show-leaf) :computed-slots ((strings-for-display "Symbols") (:slide-data '((:title "Namespace" :bullet-points ((:description "Packages represent <i>namespaces</i> for Lisp symbols") (:description "A <i>namespace</i> is like an ``area code'' for symbols") (:description "Packages allow us to avoid ``name collisions'' <ul> <li>when working in a team on a large project</li> <li>when loading third-party code into our Lisp image (``Lisp world'')</li> </ul> Packages also provide an aspect of modularity and ``object-orientedness'' to a Lisp project"))) (:title "Using Symbols for Comparison" :bullet-points ((:description "Nonkeyword Symbols live in a certain Package") (:description "These will fail <i>eql</i> equality test if in different packages") (:description "For Comparisons, use <i>Keyword Symbols</i>") (:description "<i>Keyword Symbols</i> are all in a special package called the ``Keyword'' package." :examples ((:code (eql :foo :foo) :return-value t))))) (:title "Working with Packages" :bullet-points ((:description "Make a new package for each major project" :examples ((:code (gwl:define-package :mypackage (:export #:assembly))))) (:description "Make sure to put an in-package at the top of every file you work with. <i>Every</i> Lisp file should have <i>some</i> ``in-package'' statement in its header.") (:description "In Emacs, you can use <tt>M-x fi:parse-mode-line-and-package</tt> to synchronize the package in the Emacs buffer with the in-package of the file (only necessary for newly created files).")))))))
2,575
Common Lisp
.lisp
62
38.145161
101
0.716754
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f81fb64702e6ab1143388524ed7c8ec9de0fb1af14fa3b6a8ccd6989d28249d8
36,214
[ -1 ]
36,215
input-output.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/input-output.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object input-output (slide-show-leaf) :computed-slots ((strings-for-display "Input/Output") (:slide-data `((:title "Input/Output and Streams" :bullet-points ((:description "The most basic functions for input and output are <i>read</i> and <i>print</i>.") (:description "both <i>read</i> and <i>print</i> take an optional <i>stream</i> argument, which defaults to <i>*standard-input*</i> and <i>*standard-output*</i>, respectively.") (:description "A <i>stream</i> is a theoretically infinite source or destination for data (text or binary).") (:description "By default, the global system parameters <i>*standard-input*</i> and <i>*standard-output*</i> will both be bound to <i>*terminal-io*</i>, which is an input/output stream bound to your Lisp ``toplevel'' (i.e. the <i>*common-lisp*</i> buffer in Emacs)") (:description "In general, these system parameters should <i>never</i> be explicitly changed (e.g. with <i>setq</i> or <i>setf</i>)"))) (:title "Read" :bullet-points ((:description "<i>Read</i> by itself, typed into the toplevel, just sits there and waits for you to type something in (because <i>stream</i> defaults to the toplevel ``<i>*standard-input*</i>'').") (:description "<i>read &amp;optional stream eof-error-p eof-value</i>" :examples ((:code (read) :input-string "1" :return-value 1) (:code (read) :input-string "(a b c)" :return-value (a b c)))) (:description "You can set a variable to the result of a call to read" :examples ((:code (setq myvar (read)) :input-string "Hello" :return-value Hello) (:code myvar :return-value hello))))) (:title "Print" :bullet-points ((:description "<i>Print</i> will print exactly one Lisp expression to the optional <i>stream</i> (default is <i>*standard-output*</i>), preceded by a new line and followed by a space") (:description "<i>print item &amp;optional stream</i>") (:description "By default, <i>stream</i> is the toplevel <i>*standard-output*</i>, so it just prints to the console, or <i>*common-lisp*</i> buffer" :examples ((:code (print 'hello) :print-string "hello" :return-value hello))) (:description "Notice that <i>print</i> has the <i>side-effect</i> of printing <i>item</i>, and it also <i>returns</i> the <i>item</i> as its <i>return value</i>") (:description "This <i>return value</i> is <i>not</i> being printed to the <i>stream</i>, it is only showing up in the toplevel, as is always the case for functions typed into the toplevel") (:description "For both <i>read</i> and <i>print</i>, you can specify the stream to be some destination or source other than the default. Often this would be a file in the computer filesystem.") (:description "If the <i>stream</i> is set to some other destination (e.g. a file), only the printed data will go there, not the return value") (:description "More on this later"))) (:title "The Printer" :bullet-points ((:description "Lisp's facility for emitting characters to an output stream is known as ``<i>The Printer</i>.''") (:description "The most common functions used with the <i>printer</i> are: <ul> <li><i>print</i></li> <li><i>princ</i></li> <li><i>prin1</i></li> <li><i>format</i></li> </ul>" :suppress-end-dot? t) (:description "<i>Print</i>, <i>prin1</i>, and <i>princ</i> will print exactly one Lisp expression (e.g. a List, a Symbol, a String, a Number, etc.) to an optional <i>stream</i>, which defaults to *standard-output*") (:description "<i>Princ</i> generates output fit for a human reader, while <i>print</i> and <i>prin1</i> generate output fit for the Lisp reader (i.e. the <i>read</i> function).") (:description "<i>Print</i> and <i>prin1</i> are similar, but <i>print</i> prints a newline first and a space afterward, while <i>prin1</i> does not.") (:description "<i>Format</i> is a very powerful generalization of both <i>princ</i> and <i>prin1</i>, and is what you will use most often"))) (:title "<i>Format</i>" :bullet-points ((:description "<i>Format</i> is very general and can be used for almost all output") (:description "<i>format stream format-string arg1 arg2 ... argN</i>") (:description "<i>format</i> processes the <i>format-string</i> according to the <i>args</i>, and emits the result to the specified destination stream") (:description "The <i>format-string</i> can contain <i>format directives</i> which often act as placeholders for the <i>args</i>") (:description "The most common <i>format-string</i> is <i>~a</i> which processes its argument as if by <i>princ</i>") (:description "<i>Stream</i> is a required argument, which is often specified as <i>t</i> or <i>nil</i>") (:description "If <i>stream</i> is specified as <i>T</i>, <i>format</i> will emit its result to <i>*standard-output*</i> and return <i>nil</i>" :examples ((:code (format t "Hello There ~a" 'bob) :print-string "Hello There bob" :return-value nil))) (:description "If <i>stream</i> is specified as <i>nil</i>, <i>format</i> does not print anything through side-effect, but rather it returns, in the form of a string, what it would have printed" :examples ((:code (format nil "Hello There ~a" 'bob) :return-value "Hello There bob"))) )) (:title "The <i>Format String</i>" :bullet-points ((:description "The <i>format-string</i> is a template which may contain <i>format directives</i>, which are preceded by a <i>~</i> (<i>tilde</i>)") (:description "The <i>format directives</i> form a powerful language in its own right") (:description "The most commonly used <i>format directives</i> are <i>~a</i> and <i>~s</i>, which process their arguments as if by <i>princ</i> and <i>prin1</i>, respectively" :examples ((:code (format t "~s" "some string") :print-string "\"some string\"" :return-value nil) (:code (format t "~a" "some string") :print-string "some string" :return-value nil) (:code (format t "~s" :michigan) :print-string ":michigan" :return-value nil) (:code (format t "~a" :michigan) :print-string "michigan" :return-value nil))))) (:title "The <i>Format String</i>, Cont'd" :bullet-points ((:description ,(string-append "See the ANSI specification or other " (with-output-to-string (ss) (html-stream ss ((:a :href "http://psg.com/~dlamkins/sl/chapter24.html") "online"))) " resources for a complete treatment of the syntax for <i>format directives</i>.")) (:description "<i>~F</i> is another common format directive, which processes its output as a floating-point number according to many options" :examples ((:code (format nil "~,4f" 34.433434323443) :return-value "34.4334") (:code (format nil "Hello, ~a, your rating is ~,3f" 'bill 34.433434323443) :return-value "Hello, bill, your rating is 34.433"))) (:description "Note that <i>~f</i> does not mathematically ``round'' the number in any predictable manner; if you are concerned with rounding precision, round the number explicitly (using a function such as <i>round</i>) before passing it to <i>format</i>"))) (:title "File Input and Output" :bullet-points ((:description "To read and write from and to a file, we must read and write to a <i>stream</i> which is connected to the file") (:description "The basic mechanism for connecting a stream to a file is the function <i>open</i>" :examples ((:code (defparameter *my-stream* (open "~/readme.txt")) :return-value *my-stream*) (:code *my-stream* :return-value "#<excl::character-input-file-stream ....>"))) (:description "However, when you use <i>open</i> explicitly like this, you have to remember to do a corresponding <i>close</i> later:" :examples ((:code (close *my-stream*) :return-value t))) (:description "If you print something to the file and forget to close the stream, nothing is guaranteed about the contents of the file") (:description "Plus, if your program throws an error in between the <i>open</i> and the <i>close</i>, and you cannot continue gracefully from the error, it is possible that the file will be left ``hanging'' open indefinitely") (:description "For these reasons, you will generally want to use the macro <i>with-open-file</i> rather than using <i>open</i> and <i>close</i> explicitly"))) (:title "With-open-file" :bullet-points ((:description "<i>with-open-file (stream pathname &key arguments) body</i>" :examples ((:code (let ((readme-pathname "~/readme.txt")) (with-open-file (input-stream readme-pathname) (read input-stream))) :return-value hello))) (:description "<i>With-open-file</i> automatically closes the <i>stream</i>, even if an error is thrown somewhere in the middle of the <i>body</i>") (:description "In order to write to a file, additional keyword arguments must be given<br> <i>Note</i>: in this example, the output shown with ``<i>==&gt;''</i> is what is written to the <i>file</i>, not the console or <i>*common-lisp*</i> buffer" :examples ((:code (let ((readme-pathname "~/readme.txt")) (with-open-file (output-stream readme-pathname :direction :output :if-exists :supersede :if-does-not-exist :create) (format output-stream "Hello There"))) :print-string "Hello There" :return-value nil))))) (:title "Exercises for Session 6 : Input and Output" :bullet-points ((:description "Create a file (using Emacs) which contains a simple plist, mapping keywords to values. The keywords should be actual keywords (beginning with colon), and the values can be any valid Lisp expression, such as string, number, or list") (:description "Create a function <i>read-plist</i> which takes a pathname as an argument, and reads the first valid Lisp form from the file corresponding to the pathname. For the file you just created, it should read the entire plist from the file. If the call to <i>read</i> is the final thing which happens in your program, the plist will be the return value of the function and will thus be printed in the console automatically.") (:description "Extend the above function to read the plist (into a <i>let</i> variable), then print a prompt to standard output which says ``please enter a keyword.'' It should then read an expression from standard input, and return the plist value corresponding to the expression read (if any). Note: <i>getf</i> will simply return <i>nil</i> if the keyword is not found in the plist, which is fine.") (:description "Create a function ``plist2table,'' which takes a pathname as an argument. The file corresponding to the pathname should contain a plist (same as above). Plist2table should read the plist (into a let variable). Plist2table should then emit an HTML table to standard output. The table should contain two columns and as many rows as there are entries in the plist. I will provide some macros to help with creating html tables.")))))))
12,322
Common Lisp
.lisp
287
38.637631
108
0.690327
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c3a2b6a983315c5abac52605764d3763caf0246b14d367c2968f69b0da862f16
36,215
[ -1 ]
36,216
introduction.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/introduction.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object introduction (slide-show-leaf) :computed-slots ((strings-for-display "Introduction") (slide-data `( (:title "My Background" :bullet-points ((:description "1997-present: Approaching 13 years running Genworks, a KBE tools vendor") (:description "1993-1997: at Ford Motor Company, building and administering KBE applications with ICAD Design Language") (:description ,(string-append "1983-1993:" (with-output-to-string (ss) (html-stream ss (:ul (:li "Master in Computer Science, U of Michigan") (:li "Work Experience in Database Industry (Quantum/Progress)") (:li "Work Experience in CAD Industry (Applicon)") (:li "Bachelors in Computer Science and German, U of Michigan")))))))) (:title "CL Timeline - Past" :bullet-points ((:description "Conceived in 1958") (:description "Professor John McCarthy") (:description "2nd oldest high-level computer language still in use") (:description "Still on the leading edge") (:description "<b>Designed to evolve</b>"))) (:title "One of the most popular extension languages:" :bullet-points ((:description "The Genworks GDL System" :image-url "smiley.gif") (:description "Gnu Emacs") (:description "The ICAD System") (:description "AutoCAD (AutoLisp, VisualLisp)") (:description "DesignPower Design++") (:description "Game development (Nichimen Graphics, Mirai, Naughty Dog Software)") (:description "Sawfish window manager"))) (:title "The Original RAD Environment" :bullet-points ((:description "<b><u>R</u></b>apid <b><u>A</u></b>pplication <b><u>D</u></b>evelopment") (:description "Write a prototype faster <b>than the spec</b>") (:description "Prototype is a better spec <b>than a paper spec</b>") (:description "Fine-tune the resulting prototype into a production application"))) (:title "Lisp Thrives on Complex Problems" :bullet-points ((:description "You can't completely specify something if you have never solved something like it before - you have to experiment and prototype") (:description "The Lisp environment is well-suited to supporting exploratory programming") (:description "The Lisp environment is also well-suited to supporting VERY large programs in a workable manner (e.g. the GDL System)")))))))
3,340
Common Lisp
.lisp
86
34.337209
108
0.704221
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
49510bca38547de5005c756c86b5ff8fd633c399ec24035c5796e4db73f1d691
36,216
[ -1 ]
36,217
data-structures.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/data-structures.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object data-structures (slide-show-leaf) :computed-slots ((strings-for-display "Other Data Structures") (slide-data '((:title "Hash Tables" :bullet-points ((:description "Allow very fast retrieval of data based on keys:" :examples ((:code (setq os-ratings (make-hash-table)) :return-value "<eql hash-table with 0 entries @ #x9309caa>") (:code (setf (gethash :windows os-ratings) :acceptable) :return-value :acceptable) (:code (gethash :windows os-ratings) :return-value :acceptable))) (:description "Can store database tables locally and temporarily as hash tables for very fast repeated access.") (:description "Can store a hash table in the symbol-plist of a function, to ``memoize'' return values."))) (:title "Arrays" :bullet-points ((:description "Arrays allow you to represent an indexed vector or multidimensional matrix of values") (:description "I find they are rarely necessary when working with Lisp in the context of The GDL System (you would generally use quantified objects instead)") (:description "If you might have a use for them, see the Lisp Resources at the end of this presentation for further information."))) (:title "Structures and Objects" :bullet-points ((:description "Common Lisp defines the <i>defstruct</i> macro for defining a data structure with slots") (:description "Common Lisp also contains a complete object-oriented system called CLOS (Common Lisp Object System).") (:description "Generally, the use of GDL <i>define-object</i> obviates the need for these features of the language, thus they are beyond the scope of this course (``Common Lisp for GDL Users'')") (:description "However, they are provided in the language and there is nothing which says you cannot use them, either with or without GDL's <i>define-object</i> (for example, you might program a slot of a GDL <i>define-object</i> to actually be a <i>CLOS</i> object") (:description "See the Lisp Resources at the end of this presentation for more information if you are interested"))) (:title "Exercises for Session 9 : Other Data Structures" :bullet-points ((:description "Create a ``memoized'' version of <i>factorial</i>, which stores all the values it has computed so far in a hash table. Note that you can wrap a <i>let</i> binding <b>around</b> a <i>defun</i> definition, so, for example, you can ``let'' a variable to a call to <i>(make-hash-table)</i>, so that variable (and thus the hash table), is limited to the lexical scope of that let binding, which means only that particular <i>defun</i> can see it.")))))))
3,607
Common Lisp
.lisp
87
38.045977
133
0.729954
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ec3506c8af3f225707e82d5e6ad590e15d00fda037b1cd6d6a6c9c7ee95308bd
36,217
[ -1 ]
36,218
control.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/control.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object control (slide-show-leaf) :computed-slots ((strings-for-display "Control") (:slide-data '((:title "<i>If</i> revisited" :bullet-points ((:description "<i>If test then-form else-form</i>") (:description "<i>If</i> can take only a single <i>then-form</i> and <i>else-form</i>") (:description "Use <i>progn</i> to group several expressions within a form<br> <i>Note: a progn form returns the return-value of the last form.<br> prog1 is also available, which returns the return-value of the first form</i>." :examples ((:code (if (eql status :all-systems-go) (progn (broadcast-countdown) (flash-colored-lights) (play-eerie-music) (launch-rocket)) (progn (broadcast-apology) (shut-down-rocket))) :return-value "Rocket has been launched") (:code (if (eql status :all-systems-go) (prog1 (broadcast-countdown) (flash-colored-lights) (play-eerie-music) (launch-rocket)) (prog1 (broadcast-apology) (shut-down-rocket))) :return-value "Countdown has been broadcast"))))) (:title "<tt>progn</tt> and <tt>prog1</tt>" :bullet-points ((:description "Note the use of <tt>progn</tt> and <tt>prog1</tt> in the previous example.") (:description "Some places in CL (e.g. the <i>test</i>, <i>then</i>, and <i>else</i> clauses of an <tt>if</tt> statement) accept only a single expression.") (:description "In such places, <tt>progn</tt> can be used to group expressions to be evaluated in the order they are listed, with the return-value of the last expression being the final return-value from the progn.") (:description "In such places, <tt>prog1</tt> can be used to group expressions to be evaluated in the order they are listed, with the return-value of the first expression being the final return-value from the progn.") (:description "Other places in CL accept a <i>body</i> of code (e.g. inside a function definition or inside a <tt>let</tt>), where expressions are evaluated in the order they are listed, with the return-value of the last expression being the final return-value of the code body.") (:description "No <tt>progn</tt> or <tt>prog1</tt> is needed to surround such a body of code.") (:description "The <i>only</i> time it makes sense to have a <tt>progn</tt>, <tt>prog1</tt>, or more than one expression in a body of code, is when some local or global side-effect is happening (i.e. you are modifying a value or performing some output)."))) (:title "When" :bullet-points ((:description "If there is no <i>else-form</i>, Use <i>When</i> instead of <i>If</i>") (:description "Unlike <i>If</i>, <i>When</i> can take any number of forms (like an implicit <i>progn</i>)") (:description "The return-value from the last form is returned from the <i>When</i> form (as with <i>progn</i>." :examples ((:code (when (eql database-connection :active) (read-record-from-database) (chew-on-data-from-database) (calculate-final-result)) :return-value 999))) (:description "<i>When</i> simply returns nil if the condition is not met</i>" :examples ((:code (when (> 3 4) (princ "I don't think so...")) :return-value nil))))) (:title "Logical Operators" :bullet-points ((:description "The symbol t is the default representation for True.") (:description "The symbol nil is the default representation for False." :examples ((:code (listp '(ti intel motorola)) :return-value t) (:code (listp 3.1415) :return-value nil) (:code (> 3 4) :return-value nil))))) (:title "Logical Operators, cont'd" :bullet-points ((:description "Any non-<i>nil</i> value is ``as good as'' <i>t</i>." :examples ((:code (member 'boston '(chicago detroit boston new-york)) :return-value (boston new-york)) (:code (when (member 'boston '(chicago detroit boston new-york)) '(yes it is)) :return-value (yes it is)))))) (:title "And, Or, Not" :bullet-points ((:description "and form1 form2 ... formn" :examples ((:code (listp '(chicago detroit boston new-york)) :return-value t) (:code (listp 3.1415) :return-value nil) (:code (and (listp '(chicago detroit boston new-york)) (listp 3.1415)) :return-value nil))) (:description "or form1 form2 ... formn" :examples ((:code (or (listp '(chicago detroit boston new-york)) (listp 3.1415)) :return-value t))) (:description "not form1" :examples ((:code (not nil) :return-value t) (:code (not (listp 3.1415)) :return-value t))))) (:title "Cond" :bullet-points ((:description "The use of nested <i>If</i>'s is not appropriate") (:description "Use <i>cond</i> instead.") (:description "<i>cond test-result-list-1 test-result-list-2 ... test-result-list-n</i>" :examples ((:code (let ((n 4)) (cond ((> n 10) "It's a lot") ((= n 10) "It's kind of a lot") ((< n 10) "It's not a lot"))) :return-value "It's not a lot"))) (:description "If you want the last condition do default if all else fails, use <i>t</i>" :examples ((:code (let ((n 4)) (cond ((> n 10) "It's a lot") ((= n 10) "It's kind of a lot") (t "It's not a lot"))) :return-value "It's not a lot"))))) (:title "Case" :bullet-points ((:description "If you want to conditionalize based on comparing a value against some series of constants, use <i>case</i>") (:description "Case only works if the value will match with <i>eql</i>, i.e. use it for keywords, symbols, integers, but not for strings, lists, or floating-point numbers. " :examples ((:code (let ((color :red)) (case color (:blue "Blue is okay") ((:red :orange) "Red or orange are actually her favorite colors") (:green "Are you nuts?"))) :return-value "Red or orange are actually her favorite colors"))) (:description "For matching strings, you have to use <i>cond</i> " :examples ((:code (let ((color "red")) (cond ((string-equal color "blue") "Blue is okay") ((string-equal color "red") "Red is actually her favorite color") ((string-equal color "green") "Are you nuts?"))) :return-value "Red is actually her favorite color"))) (:description "Use <i>otherwise</i> as a catch-all for <i>case</i>" :examples ((:code (let ((color :orange)) (case color (:blue "Blue is okay") (:red "Red is actually her favorite color") (:green "Are you nuts?") (otherwise "We have never heard of that!"))) :return-value "We have never heard of that!"))) (:description "Use <i>ecase</i> to throw an error for an invalid case</i>" :examples ((:code (let ((color :orange)) (ecase color (:blue "Blue is okay") (:red "Red is actually her favorite color") (:green "Are you nuts?"))) :return-value "Error: :orange fell through a ecase form. The valid cases were :blue, :red, and :green."))))) (:title "Iteration revisited" :bullet-points ((:description "Dolist, Dotimes, Mapcar, Mapc") (:description "I tend to stay away from Loop and Do") (:description "Mapcar is often much less verbose than Dolist" :examples ((:code (defun twice (num) (* num 2)) :return-value twice) (:code (let ((result-list nil)) (dolist (elem '(3 4 8 2) result-list) (setq result-list (append result-list (list (twice elem)))))) :return-value (6 8 16 4)) (:code (mapcar #'twice '(3 4 8 2)) :return-value (6 8 16 4)))) (:description "You can return early from <i>dolist</i> or <i>dotimes</i> with <i>return</i>" :examples ((:code (dolist (elem '(3 4 55 2) result-list) (if (< elem 50) (setq result-list (append result-list (list (twice elem)))) (return "we cannot handle numbers bigger than 50"))) :return-value "we cannot handle numbers bigger than 50"))))) (:title "Exercises" :bullet-points ((:description "We will hold off on exercises until we have learned more about <i>Functions</i> in the next session.")))))))
9,554
Common Lisp
.lisp
257
31.124514
131
0.633828
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
53bf54aacd6d84682702d0e1a7de1e8bb8f838ecededa447dc9f860b7868b343
36,218
[ -1 ]
36,219
numbers.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/numbers.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object numbers (slide-show-leaf) :computed-slots ((strings-for-display "Numbers" :uncached) (slide-data `((:title "Types" :bullet-points ((:description "Integers" :examples ((:code 1) (:code 38) (:code 3456765499788684748455767674834355858333442))) (:description "Floating Point" :examples ((:code 253.75) (:code 5.32e72))) (:description "Ratios" :examples ((:code 6/7) (:code 354/355))) (:description "Complex" :examples ((:code (sqrt -25) :return-value ,(sqrt -25)))))) (:title "Comparison: ``=''" :bullet-points ((:description "Any number of arguments") (:description "Returns <i>T</i> if difference among arguments is Zero") (:description "More than two args same as conjunction" :examples ((:code (= 3 3.0 3.00)) (:code (and (= 3 3.0) (= 3.0 3.00))))) (:description "Do not use ``='' for floating-point numbers:" :examples ((:code (= 1.599999999 1.6) :return-value nil))) (:description "Check the magnitude of the difference or GDL defines ``near-to?'' for this purpose:" :examples ((:code (near-to? 1.555555559 1.6) :return-value t))))) (:title "Comparison, cont'd: ``&gt;,'' ``&lt;,'' ``&lt;=,'' ``&gt;=,'' and ``/=''" :bullet-points ((:description "Any number of arguments") (:description "More than two args same as conjunction" :examples ((:code (> 3 4 5)) (:code (and (> 3 4) (> 4 5))))))) (:title "Predicates" :bullet-points ((:description "plusp" :examples ((:code (plusp 7) :return-value t))) (:description "minusp" :examples ((:code (minusp 7) :return-value nil) (:code (minusp -7) :return-value t))) (:description "zerop" :examples ((:code (zerop (- 7 7)) :return-value t))) (:description "oddp, evenp" :examples ((:code (oddp 7) :return-value t) (:code (evenp (twice 7)) :return-value t))))) (:title "Max, Min" :bullet-points ((:description "Take any number of arguments" :examples ((:code (max 3 4 5 3 4 2 6 4 2 3) :return-value 6) (:code (min 3 4 5 3 4 2 6 4 2 3) :return-value 2))) (:description "If you have a list you must use <i>apply</i> with #'min or #'max" :examples ((:code (setq list (list 3 4 5 3 4 2 6 4 2 3))) (:code (apply #'max list) :return-value 6) (:code (apply #'min list) :return-value 2))) (:description "For very long lists, use (GDL-provided) <i>most</i> and <i>least</i>"))) (:title "Arithmetic Operations" :bullet-points ((:description "fn arg1 arg2 ... argn" :examples ((:code (+ 1 2) :return-value 3) (:code (+ 1 2 3 4 5) :return-value 15) (:code (* (+ 1 2) 2) :return-value 6) (:code (/ 4 2) :return-value 2) (:code (+) :return-value 0))))) (:title "Incrementing and Decrementing" :bullet-points ((:description "Nondestructive Operators" :examples ((:code (1+ 7) :return-value 8) (:code (1- 7) :return-value 6))) (:description "Destructive Operators" :examples ((:code (setq num 7)) (:code (incf num) :return-value 8) (:code num :return-value 8) (:code (decf num) :return-value 7) (:code num :return-value 7)))))))))
4,610
Common Lisp
.lisp
147
24.414966
107
0.57873
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
beb5fd6106f35f54220c68be9c998d24649ce36b8ef86116150c1ca72551c10d
36,219
[ -1 ]
36,220
functions.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/functions.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object functions (slide-show-leaf) :computed-slots ((strings-for-display "Functions" :uncached) (slide-data '((:title "Functions" :bullet-points ((:description "Understanding functions is one of the keys to understanding Lisp - <i>Paul Graham</i>") (:description "Named Functions are defined with <i>Defun</i> (``Definition of a Function'')") (:description "Technically, a named function is a <i>Symbol</i> with a <i>Function object</i> stored in its ``function-slot''" :examples ((:code (defun add-3 (num) (+ num 3)) :return-value add-3) (:code (symbol-function 'add-3) :return-value "#<Interpreted Function add-3>") (:code (function add-3) :return-value "#<Interpreted Function add-3>"))) (:description "<i>#'</i> is to <i>function</i> as <i>'</i> is to <i>quote</i>" :examples ((:code "(quote (+ 1 2))" :return-value (+ 1 2)) (:code '(+ 1 2) :return-value (+ 1 2)) (:code "(function add-3)" :return-value "#<Interpreted Function add-3>") (:code #'add-3 :return-value "#<Interpreted Function add-3>"))))) (:title "Passing a function as an argument to another function" :bullet-points ((:description "When passing a function as an argument, we must pass the <i>function object</i>") (:description "The <i>Function object</i> for a named function can be obtained using the function <i>Function</i>" :examples ((:code "(mapcar (function add-3) '(2 3 4))" :return-value (5 6 7)))) (:description "Or with the shorthand version <i>#'</i>:" :examples ((:code (mapcar #'add-3 '(2 3 4)) :return-value (5 6 7)) (:code (sort (list 6 4 3 9) #'<) :return-value (3 4 6 9)) (:code (sort (list 6 4 3 9) #'>) :return-value (9 6 4 3)))))) (:title "Anonymous (Unnamed) Functions" :bullet-points ((:description "<i>Unnamed</i> functions can be defined using <i>lambda</i>") (:description "You can substitue a <i>Lambda Expression</i> anywhere you use a <i>Function Name</i>" :examples ((:code (mapcar #'add-3 '(2 3 4)) :return-value (5 6 7)) (:code (mapcar #'(lambda(num) (+ num 3)) '(2 3 4)) :return-value (5 6 7)))))) (:title "Using an anonymous predicate function with <i>Sort</i>" :bullet-points ((:description "<i>Sort</i> takes a <i>predicate</i> function (a function returning <i>T</i> or <i>NIL</i>), which must take 2 arguments") (:description "<i>Strings</i> can be compared lexically using <i>String&lt;</i> or <i>String&gt;</i>. More on <i>Strings</i> later." :examples ((:code (sort (list (list 4 "Buffy") (list 2 "Keiko") (list 1 "Judy") (list 3 "Aruna")) #'(lambda(pair1 pair2) (< (first pair1) (first pair2)))) :return-value ((1 "Judy") (2 "Keiko") (3 "Aruna") (4 "Buffy"))) (:code (sort (list (list 1 "Judy") (list 2 "Keiko") (list 3 "Aruna") (list 4 "Buffy")) #'(lambda(pair1 pair2) (string< (second pair1) (second pair2)))) :return-value ((3 "Aruna") (4 "Buffy") (1 "Judy") (2 "Keiko"))))))) (:title "Function Arguments, revisited" :bullet-points ((:description "Functions can take optional arguments using <i>&optional</i> in the argument list") (:description "Functions can take optional keyword arguments using <i>&key</i> in the argument list") (:description "Functions can take any number of arguments using <i>&rest</i> in the argument list"))) (:title "Optional Arguments" :bullet-points ((:description " <pre><i> defun function-name (&optional (arg1-name arg1-default) (arg2-name arg2-default) ... (arg3-name arg3-value))</i></pre>" :examples ((:code (defun greeting (&optional (username "Jake")) (list 'hello 'there username)) :return-value greeting) (:code (greeting) :return-value (hello there "Jake")) (:code (greeting "Joe") :return-value (hello there "Joe")))))) (:title "Keyword Arguments" :bullet-points ((:description " <pre><i> defun function-name (&key (arg1-name arg1-default) (arg2-name arg2-default) ... (arg3-name arg3-value))</i></pre>") (:description "Keyword arguments are order-independent and improve readability of code." :examples ((:code (defun greeting (&key (username "Jake") (greeting "how are you?")) (format nil "Hello there ~a, ~a" username greeting)) :return-value greeting) (:code (greeting) :return-value "Hello there Jake, how are you?") (:code (greeting :greeting "how have you been?") :return-value "Hello there Jake, how have you been?") (:code (greeting :greeting "how have you been?" :username "Joe") :return-value "Hello there Joe, how have you been?"))))) (:title "Keyword Arguments, Cont'd" :bullet-points ((:description "The Keyword Argument <i>:test</i> is often used to pass an optional function-object to a function") (:description "Generally, the <i>:test</i> keyword argument will allow you to specify a match function other than the default of <i>eql</i>." :examples ((:code (member "a" '("a" "b" "c" "d")) :return-value nil) (:code (member "a" '("a" "b" "c" "d") :test #'string-equal) :return-value ("a" "b" "c" "d")) (:code (member "a" '("a" "b" "c" "d") :test #'string-equal) :return-value ("a" "b" "c" "d")) (:code (remove "a" '("a" "b" "c" "d")) :return-value ("a" "b" "c" "d")) (:code (remove "a" '("a" "b" "c" "d") :test #'string-equal) :return-value ("b" "c" "d")) (:code (remove 3 '(("a" 1) ("b" 2) ("c" 3) ("d" 4))) :return-value (("a" 1) ("b" 2) ("c" 3) ("d" 4))) (:code (remove 3 '(("a" 1) ("b" 2) ("c" 3) ("d" 4)) :test #'(lambda(x y) (eql x (second y)))) :return-value (("a" 1) ("b" 2) ("d" 4))))) (:description "The keyword argument <i>:key</i> can also sometimes be used to apply a function to elements of a list before trying to match (compare the following with last example above, with same result:" :examples ((:code (remove 3 '(("a" 1) ("b" 2) ("c" 3) ("d" 4)) :key #'second) :return-value (("a" 1) ("b" 2) ("d" 4))))))) (:title "Recursion" :bullet-points ((:description "Recursion is sometimes an alternative to explicit looping:" :examples ((:code (defun factorial (n) (if (or (= n 0) (= n 1)) 1 (* n (factorial (- n 1))))) :return-value factorial) (:code (factorial 4) :return-value 24))) (:description "As development iterates, recursion can be made more efficient with tail recursion and function memoization."))) (:title "Formulating a Recursion" :bullet-points ((:description "Show how to solve the smallest version of the problem - the <i>base case</i> - by some finite number of operations.") (:description "Show how to solve the problem in the general case by breaking it down into a finite number of similar, but smaller problems.") (:description "Example: compute the length of a list") (:description "The length of an empty list is 0.") (:description "In the general case, the length of a proper list is the length of its rest plus 1.") (:description "Code:" :examples ((:code (defun g-length (lst) (if (null lst) 0 (+ (g-length (rest lst)) 1))) :return-value g-length) (:code (g-length nil) :return-value 0) (:code (g-length '(lisp rules)) :return-value 2))))) (:title "Exercises for Session 5 : Functions" :bullet-points ( (:description "Write a function, <i>sort-numbers</i> using <i>safe-sort</i>, which will sort a list of numbers in either ascending or descending order, depending on a keyword argument <i>:ordering</i>. The value of <i>:Ordering</i> should be a keyword, either <i>:ascending</i> or <i>:descending</i>, default to <i>:ascending</i>, and the program should throw an error if an argument other than one of these two is given." :examples ((:code (sort-numbers '(4 3 2 6 5 7 6)) :return-value (2 3 4 5 6 6 7)) (:code (sort-numbers '(4 3 2 6 5 7 6) :ordering :ascending) :return-value (2 3 4 5 6 6 7)) (:code (sort-numbers '(4 3 2 6 5 7 6) :ordering :descending) :return-value (7 6 6 5 4 3 2)) (:code (sort-numbers '(4 3 2 6 5 7 6) :ordering :up) :return-value some-error))) (:description "Extend the above <i>sort-numbers</i> function to accept <i>:ordering</i> values of <i>:up</i> (synonymous with <i>:ascending</i>) and <i>:down</i> (synonymous with <i>:descending</i>)" :examples ((:code (sort-numbers '(4 3 2 6 5 7 6) :ordering :ascending) :return-value (2 3 4 5 6 6 7)) (:code (sort-numbers '(4 3 2 6 5 7 6) :ordering :descending) :return-value (7 6 6 5 4 3 2)) (:code (sort-numbers '(4 3 2 6 5 7 6) :ordering :big-to-small) :return-value some-error))) (:description "Evolve the above function to a new function <i>sort-pairs</i>, which accepts a list of lists, where each internal list is a pair with a number and a string. By default, <i>sort-pairs</i> should sort the lists numerically according to the numbers, but it should take a keyword argument <i>:sort-by</i> which has valid values of <i>:number</i> or <i>:string</i>. If <i>:string</i> is specified, the lists should be sorted according to the string rather than the number. <p> The function must still accept the :ordering keyword as above. <p> <ul> <b><i>Hints:</i></b> <li>Remember to use <i>string&lt;</i> and <i>string&gt;</i> to compare strings.</li> <li>Of course, you can just use &lt; and &gt; to compare numbers.</li> </ul> " :examples ((:code (sort-pairs '((4 "Buffy") (2 "Keiko") (1 "Judy") (3 "Aruna"))) :return-value ((1 "Judy") (2 "Keiko") (3 "Aruna") (4 "Buffy"))) (:code (sort-pairs '((4 "Buffy") (2 "Keiko") (1 "Judy") (3 "Aruna")) :sort-by :string) :return-value ((3 "Aruna") (4 "Buffy") (1 "Judy") (2 "Keiko"))))) (:description "Extend the above function to handle the number-string pairs in either order. <i>Hints:</i> <ul> <li>You can find out if something is a number with <i>numberp</i></li> <li>You can find out if something is a string with <i>stringp</i></li> </ul> " :examples ((:code (sort-pairs-2 '((4 "Buffy") ("Keiko" 2) (1 "Judy") ("Aruna" 3))) :return-value ((1 "Judy") ("Keiko" 2) ("Aruna" 3) (4 "Buffy"))) (:code (sort-pairs-2 '(("Buffy" 4) (2 "Keiko") ("Judy" 1) (3 "Aruna")) :sort-by :string) :return-value ((3 "Aruna") ("Buffy" 4) ("Judy" 1) (2 "Keiko"))))) (:description "Revisit <i>set-difference-o</i> and <i>intersection-o</i>, and allow them to accept a <i>:test</i> keyword argument.")))))))
12,200
Common Lisp
.lisp
326
31.794479
132
0.611272
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
734887276488a7fcbb6706d2cbe65768bc2f7814405bcefc90522cb993e0024e
36,220
[ -1 ]
36,221
lists.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/lists.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object lists (slide-show-leaf) :computed-slots ((strings-for-display "Lists") (:slide-data '((:title "Simple Conditionals" :bullet-points ((:description "Introduced here so we can use them in List examples") (:description "<i>if test then-form else-form</i>" :examples ((:code (if (> 3 4) 'yes 'no) :return-value no))) (:description "<i>when test result-forms</i>" :examples ((:code (when (< 3 4) (action-1) (action-2) 'yes) :return-value 'yes) (:code (when (> 3 4) (action-1) (action-2) 'yes) :return-value nil) )) (:description "<i>unless test result-forms</i> (opposite of <i>when</i>)" :examples ((:code (unless (< 3 4) (action-1) (action-2) 'yes) :return-value nil) (:code (unless (> 3 4) (action-1) (action-2) 'yes) :return-value 'yes))))) (:title "Length of a List" :bullet-points ((:description "length list" :examples ((:code (length '(gm ford chrysler volkswagen)) :return-value 4) (:code (length nil) :return-value 0) (:code (defun our-length (list) (if (null list) 0 (+ (our-length (rest list)) 1))) :return-value our-length) (:code (our-length '(gm ford chrysler volkswagen)) :return-value 4))))) (:title "Member of a List" :bullet-points ((:description "member item list" :examples ((:code (member 'dallas '(boston san-francisco portland)) :return-value nil) (:code (member 'san-francisco '(boston san-francisco portland)) :return-value (san-francisco portland)) (:code (member 'portland '(boston san-francisco portland)) :return-value (portland)) (:code (member 'boston '(detroit chicago boston san-francisco portland)) :return-value (boston san-francisco portland)) (:code (defun our-member (elem list) (if (null list) nil (if (eql elem (first list)) list (our-member elem (rest list))))) :return-value our-member) (:code (our-member 'boston '(detroit chicago boston san-francisco portland)) :return-value (boston san-francisco portland)))) (:description "rest of list starting at found member is returned.") (:description "<b>Note:</b> anything that is NOT NIL is considered TRUE." :suppress-end-dot? t))) (:title "Getting part of a List (treating the list as a Sequence)" :bullet-points ((:description "<i>subseq list start-position end-position</i><br><br> <i><font color=\"red\">Note: element at end-position is NOT included in the result; the preceding element will be the last element in the result.</font></i><br><br>" :suppress-end-dot? t :examples ((:code (subseq '(a b c d) 1 3) :return-value (b c)) (:code (subseq '(a b c d) 1 2) :return-value (b)) (:code (subseq '(a b c d) 1) :return-value (b c d)))))) (:title "Appending Lists" :bullet-points ((:description "append list1 list2" :examples ((:code (setq *my-slides* '(introduction welcome lists functions)) :return-value (introduction welcome lists functions)) (:code (append *my-slides* '(numbers)) :return-value (introduction welcome lists functions numbers)) (:code *my-slides* :return-value (introduction welcome lists functions)) (:code (setq *my-slides* (append *my-slides* '(numbers))) :return-value (introduction welcome lists functions numbers)) (:code *my-slides* :return-value (introduction welcome lists functions numbers)))))) (:title "Adding Elements to a List" :bullet-points ((:description "<i>cons elem list</i>" :examples ((:code (cons 'a '(b c d)) :return-value (a b c d)))))) (:title "Removing Elements from Lists" :bullet-points ((:description "remove element list" :examples ((:code (setq *data* '(1 2 3 1000 4)) :return-value (1 2 3 1000 4)) (:code (remove 1000 *data*) :return-value (1 2 3 4)) (:code *data* :return-value (1 2 3 1000 4)) (:code (setq *data* (remove 1000 *data*)) :return-value (1 2 3 4)) (:code *data* :return-value (1 2 3 4)))))) (:title "Sorting Lists" :bullet-points ((:description "<i>sort list predicate-fn</i>" :examples ((:code (setq *data* (list 1 3 5 7 2 4 6)) :return-value (1 3 5 7 2 4 6)) (:code (setq *data* (sort *data* #'<)) :return-value (1 2 3 4 5 6 7)) (:code (setq *data* (sort *data* #'>)) :return-value (7 6 5 4 3 2 1)))) (:description "<font color=\"red\">Warning: sort is a DESTRUCTIVE function</font>") (:description "Most Lisp functions are NON-destructive; they simply return values, without modifying their arguments.") (:description "Destructive functions can be used in later iterations of development to save on memory and improve performance.") (:description "safe-sort is non-destructive version of sort defined by Genworks GDL."))) (:title "Treating a List as a Set" :bullet-points ((:description "No inherent ordering in a Set") (:description "<i>union list1 list2 ... listn</i>" :examples ((:code (union '(1 2 3) '(2 3 4)) :return-value (1 2 3 4)) (:code (union '(1 2 3) '(2 3 4)) :return-value (2 3 4 1)))) (:description "<i>intersection list1 list2</i>" :examples ((:code (intersection '(1 2 3) '(2 3 4)) :return-value (2 3)))) (:description "<i>set-difference list1 list2</i>" :examples ((:code (set-difference '(1 2 3 4) '(2 3)) :return-value (4 1)))))) (:title "Mapping" :bullet-points ((:description "<i>mapcar #'fn list1 list2 ... listn</i>" :examples ((:code (mapcar #'twice '(1 2 3 4)) :return-value (2 4 6 8)))) (:description "Lambda (unnamed) functions are used <b>very</b> frequently with mapcar. More on this later.") (:description "Also mapc, mapcan, map, etc... more on these later."))) (:title "Property Lists" :bullet-points ((:description "A.K.A. ``Plists''") (:description "Provide a simple yet powerful way to handle keyword-value pairs") (:description "A keyword is a symbol beginning with a colon. More on them later.") (:description "A Plist is a list made up of keyword/value pairs. The values may or may not be keywords.") (:description "A Plist <b>must</b> have an even number of elements or you will land in the debugger.") (:description "Access using <i>getf plist keyword</i>" :examples ((:code (getf (list :michigan :lansing :illinois :springfield :pennsylvania :harrisburg) :illinois) :return-value :springfield))) (:description "Can update using <i>setf (getf plist keyword) value</i>" :examples ((:code (setq *state-data* (list :michigan :lansing :illinois :springfield :pennsylvania :harrisburg)) :return-value (:michigan :lansing :illinois :springfield :pennsylvania :harrisburg)) (:code (setf (getf *state-data* :michigan) :pontiac) :return-value :pontiac) (:code (getf *state-data* :michigan) :return-value :pontiac))))) (:title "Property Lists, Cont'd" :bullet-points ((:description "More Examples:" :examples ((:code (setq os-ratings (list :unix "good" :windows "bad")) :return-value (:unix "good" :windows "bad")) (:code (getf os-ratings :windows) :return-value "bad") (:code (setf (getf os-ratings :windows) "atrocious") :return-value "atrocious") (:code (getf os-ratings :windows) :return-value "atrocious"))))) (:title "Property Lists, Cont'd" :bullet-points ((:description "Plists can be and often are ``nested:''" :examples ((:code (setq os-ratings (list :unix "good" :linux "better" :windows (list :openness "low" :performance "low" :security "low" :price "high"))) :return-value (:unix "good" :linux "better" :windows (:openness "low" :performance "low" :security "low" :price "high"))) (:code (getf (getf os-ratings :windows) :performance) :return-value "low") (:code (setf (getf (getf os-ratings :windows) :performance) "abysmal") :return-value "abysmal") (:code (getf (getf os-ratings :windows) :performance) :return-value "abysmal"))))) (:title "Exercises for Session 3 : Lists" :bullet-points ( (:description "Write a recursive and iterative version of a function <i>dots number</i> which takes a number and prints that many dots (you can print a dot by calling <i>(princ \".\")</i>).") (:description "Write a recursive function <i>nth-rest n list</i>, which returns the result of applying <i>rest</i> n times to <i>list</i> (equivalent to the Lisp function <i>nthcdr</i>)." :examples ((:code (nth-rest 2 '(a b c d e f)) :return-value (c d e f)) (:code (rest (rest '(a b c d e f))) :return-value (c d e f)))) (:description "Write a recursive function <i>our-nth n list</i>, which returns the nth element of list (equivalent to the Lisp function <i>nth</i>.<br> <i>Hint: implement this using nth-rest from previous exercise</i> (My solution is one line)" :examples ((:code (our-nth 2 '(a b c d e f)) :return-value c))) (:description "Write a recursive function <i>our-getf plist keyword</i>, which behaves as <i>getf</i> (don't worry about being able to <i>setf (getf plist keyword> value</i>)<br> <i>Hint: nth-rest might be of assistance in implementing this as well.</i> (My solution is four lines)." :examples ((:code (our-getf '(:germany :berlin :england :london :finland :helsinki :norway :oslo :france :paris) :finland) :return-value :helsinki))) (:description "<i>The following are bonus exercises which may require some concepts we have not learned yet -- we will revisit them later if you can't do them now.</i>") (:description "Write a function, <i>filter-in fn list</i>, which takes a <i>function</i> and a <i>list</i>, and returns a new list containing all elements of <i>list</i> for which the <i>function</i> returns non-nil (equivalent to the CL function <i>remove-if-not</i>). (My solution is four lines)." :examples ((:code (filter-in #'oddp '(4 2 6 5 8 3 4 9)) :return-value (5 3 9)) (:code (filter-in #'listp '(hello (how are you) well (i am okay) but (a bit tired))) :return-value ((how are you) (i am okay) (a bit tired))))) (:description "Write a function, <i>position-filter fn list</i>, which takes a <i>function</i> and a <i>list</i>, and returns a new list containing all elements from <i>list</i> for which the <i>function</i> returns true when applied to that element's (zero-indexed) position in the <i>list</i>: (My solution is six lines)." :examples ((:code (position-filter #'oddp '(a b c d e f)) :return-value (b d f)) (:code (position-filter #'evenp '(:germany :berlin :england :london :finland :helsinki :norway :oslo :france :paris)) :return-value (:GERMANY :ENGLAND :FINLAND :NORWAY :FRANCE)))) (:description "Write a function, <i>set-difference-o set1 set2</i>, which works just like <i>set-difference</i>, except it retains the ordering of elements in the set1. (My solution is four lines)." :examples ((:code (set-difference-o '(a b c d e f) '(e d b)) :return-value (a c f)) (:code (set-difference '(a b c d e f) '(e d b)) :return-value (f c a)))) (:description "Write a function, <i>intersection-o set1 set2</i>, which works just like <i>intersection</i>, except it retains the ordering of elements in the set1. (My solution is four lines)." :examples ((:code (intersection-o '(a b c d e f) '(e d b)) :return-value (b d e)) (:code (intersection '(a b c d e f) '(e d b)) :return-value (e d b))))))))))
16,142
Common Lisp
.lisp
444
24.977477
121
0.526112
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8599eb48cbba2050be28212db413d29d36ebc4197f0ce9b16a5ef981d430c502
36,221
[ -1 ]
36,222
conclusion.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/conclusion.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object conclusion (slide-show-leaf) :computed-slots ((strings-for-display "Conclusion") (:slide-data `((:title "Congratulations" :bullet-points ((:description "If you have understood most of these slides and completed most of the exercises, Common Lisp should now be more familiar and less of a mystery.") (:description ,(string-append "For further resources, see the " (with-output-to-string(ss)(html-stream ss ((:a :href "http://www.common-lisp.net") "Common Lisp.net"))) ", " ", and the " (with-output-to-string(ss)(html-stream ss ((:a :href "http://www.lispworks.com/reference/HyperSpec/Front/index.htm") "Common Lisp Hyperspec"))) " for the complete official specification of the language." )) (:description ,(string-append "For creating complete and well-rounded CL-based applications, especially web-based and technical/engineering applications, please consider using the open-source " (with-output-to-string(ss)(html-stream ss ((:a :href "http://gendl.org") "Gendl Project"))) " or the commercial Genworks " (with-output-to-string(ss)(html-stream ss ((:a :href "http://www.genworks.com/products/index.html") "General-purpose Declarative Language (GDL)"))) ".")) (:description "Genworks offers G102, as a followup to this course, for quickly coming up to speed in GDL.") (:description "Thank you for your attention, and please do not hesitate to voice questions and comments on this training course. Ask your instructor or send them to info at genworks dot com."))) ))))
2,529
Common Lisp
.lisp
51
45.117647
147
0.723001
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8258789189d3af760231b1cca1baf55c5f95480f8735b4b3227efd8154895615
36,222
[ -1 ]
36,223
macros.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/macros.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object macros (slide-show-leaf) :computed-slots ((strings-for-display "Macros") (:slide-data `((:title "Programs which write Programs" :bullet-points ((:description "Using <i>macros</i> is the most common way to write code which generates other code") (:description "In everyday CL and GDL development, you almost never have to write your own macros (more on this later).") (:description "A <i>macro</i> will convert one Lisp expression into another Lisp expression, according to its <i>arguments</i>, before the final expression is actually evaluated or compiled") (:description "Macros can contain other macros, and potentially an expression can be transformed many, many times before it actually gets evaluated or compiled"))) (:title "Common pre-defined Macros" :bullet-points ((:description "Pre-defined macros often start with ``def'' or ``with-''") (:description ,(with-output-to-string(ss) (net.html.generator:html-stream ss ((:table :border 1) ((:tr :bgcolor "yellow") (:td ((:font :size 7) (:b "defun"))) ((:td :bgcolor "white") ((:font :size 7) "Binds a symbol's " (:i "function-slot") " to a " (:i "lambda expression (function object)")))) ((:tr :bgcolor "yellow") (:td ((:font :size 7) (:b "defparameter"))) ((:td :bgcolor "white") ((:font :size 7) "Binds a symbol's " (:i "value-slot") " to a " (:i "value")))) ((:tr :bgcolor "yellow") (:td ((:font :size 7)(:b "define-object") " (GDL)")) ((:td :bgcolor "white") ((:font :size 7) "Creates a named GDL object definition (and CLOS class definition)"))))))) (:description ,(with-output-to-string(ss) (net.html.generator:html-stream ss ((:table :border 1) ((:tr :bgcolor "yellow") (:td ((:font :size 7) (:b "with-open-file"))) ((:td :bgcolor "white") ((:font :size 7) "Wraps a body with automatic opening and closing of a file"))) ((:tr :bgcolor "yellow") (:td ((:font :size 7) (:b "with-output-to-string"))) ((:td :bgcolor "white") ((:font :size 7) "Captures stream output into a string"))))))))) (:title "Backquote (`)" :bullet-points ((:description "Backquote provides a convenient mechanism for generating Lisp expressions") (:description "By itself, it behaves just like <i>quote</i>, but used in conjunction with comma (,) it allows you to create templates of lists") (:description "This way, macros look very similar to the forms they will produce" :examples ((:code (let ((guy "bob")) `(format nil "Hello, ~a" ,guy)) :return-value (format nil "Hello, ~a" "bob")))))) (:title "A Simple Example" :bullet-points ((:description "Often, macros are used to automatically ``wrap'' a <i>body</i> of Lisp code with some other code:" :examples ((:code (defmacro with-html-tag (tag &rest body) `(progn (format t "~&&lt;~(~A~)&gt;~%" ',tag) ,@body (format t "~&&lt;/~(~A~)&gt;~%" ',tag))) :return-value with-html-tag) (:code (with-html-tag b (format t "hello")) :print-string "<pre><code> <b> hello </b><code></pre>" :return-value nil))))) (:title "When to use Macros" :bullet-points ((:description "In normal GDL development, you almost never use macros") (:description "The use of macros is not appropriate for ``inlining'' code") (:description "Use macros <i>only</i> when true source code transformation is required.")))))))
4,604
Common Lisp
.lisp
121
32.53719
121
0.636773
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
19be645973a0a4ecd12c1095ea1e650e56b1614eef8202f9c53f1f8b207f02b6
36,223
[ -1 ]
36,224
welcome.lisp
lisp-mirror_gendl/documentation/training/g101/slides/source/welcome.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g101) (define-object welcome (slide-show-leaf) :computed-slots ((strings-for-display "Welcome to Lisp") (:slide-data '((:title "S-expressions" :bullet-points ((:description " Lisp source code is made up of Symbolic Expressions, or S-Expressions. Each S-expressions is either: <ul> <li>a list</li> <li>an atom</li> </ul>" :examples ((:code '(2 3 4) :return-value (2 3 4)) (:code '(("red" 0) ("white" 1) ("blue" 2)) :return-value (("red" 0) ("white" 1) ("blue" 2))) (:code '(a "b" :c (1 2 3 "four")) :return-value (a "b" :c (1 2 3 "four"))) (:code 'a :return-value a) (:code "b" :return-value "b") (:code :c :return-value :c)) :suppress-end-dot? t))) (:title "S-Expression Syntax" :bullet-points ((:description "Prefix notation." :examples ((:code (fn arg1 arg2 arg3 "..." argN) :return-value some-return-value) (:code (+ 2 3 4) :return-value 9) (:code (fn1 (fn2 arg1 arg2) (fn3 arg3 arg4) arg5) :return-value some-return-value) (:code (* (- 7 1) (- 4 2) 2) :return-value 24))))) (:title "Lisp Syntax Simplicity" :bullet-points ((:description "That's really all there is to know about the syntax of the language") (:description "It is as clean and simple as you can get.") (:description "No ambiguities, no special cases") (:description "A welcome relief from the syntax of other popular languages such as Perl, C++, etc..."))) (:title "S-expressions to be Evaluated as Code" :bullet-points ((:description "When S-exps are to be evaluated at runtime, certain rules apply:") (:description "Symbols evaluate as variables" :examples ((:code *print-length* :return-value nil))) (:description "Other atoms (numbers, strings, keyword symbols, quoted symbols) evaluate to themselves" :examples ((:code 42 :return-value 42) (:code :key-1 :return-value :key-1) (:code 'a :return-value a))) (:description "Unquoted lists evaluate as function calls or macro-expansions, driven by the symbol at the beginning of the list" :examples ((:code (+ 1 2) :return-value 3) (:code (string-upcase "hey now") :return-value "HEY NOW") (:code (string-upcase (with-open-file (in "/tmp/data.in") (read in))) :return-value "[first S-exp in text of file]"))))) (:title "When Arguments are S-Expressions" :bullet-points ((:description "If any of the arguments are themselves expressions they are evaluated in the same manner") (:description "The sub-expression (i.e. expression nested within another expression) is evaluated, and its result is passed as an argument") (:description "(fn1 (fn2 arg1 arg2) (fn3 arg3 arg4) arg5)" :examples ((:code (* (- 7 1) (- 4 2) 2) :return-value 24))))) (:title "Variable Number of Arguments" :bullet-points ( (:description "In Lisp - because of prefix notation" :examples ((:code (+ 1 2 3 4 5 6 7) :return-value 28))) (:description "No ambiguity or precedence rules to remember regarding Order of Operations") (:description "Functions potentially can take any number of arguments (including zero)" :examples ((:code (+) :return-value 0) (:code (+ 1) :return-value 1))) (:description "Functions can also have certain required arguments" :examples ((:code (/ 2) :return-value 1/2) (:code (- 2) :return-value -2))) (:description "Most modern CL development environments (e.g. Slime) will tell you what are the required arguments (if any) when you insert a function name."))) (:title "Turning off Evaluation" :bullet-points ((:description "<tt>(+ 1 2)</tt> evaluates to 3") (:description "Sometimes you want to turn off expression evaluation") (:description "<tt>(quote (+ 1 2))</tt> evaluates to <tt>(+ 1 2)</tt>") (:description "Common Lisp defines ' as an abbreviation for quote") (:description "<tt>'(+ 1 2)</tt> evaluates to <tt>(+ 1 2)</tt>") (:description "Note that <tt>quote</tt> is one of a few <i>special operators</i> in Common Lisp (you can see that it is not an ordinary function, otherwise it would evaluate its arguments).") (:description "Note also that lists returned by <tt>quote</tt> (unlike lists returned by <tt>list</tt>) may be assumed to be <i>immutable</i> -- that is, you should never modify them in place using any destructive operators (no need to worry about this for now)."))) (:title "Lisp Data Types" :bullet-points ((:description " Usual Data Types in Other Languages <ul> <li>Numbers</li> <li>Strings</li> </ul>" :suppress-end-dot? t) (:description " Fundamental Lisp Data Types <ul> <li>Symbols</li> <li>Lists</li> </ul>" :suppress-end-dot? t))) (:title "What are Symbols?" :bullet-points ((:description "Symbols are OBJECTS") (:description "They are NOT simply strings.") (:description "They have a name, and can have a value, function and property-list") (:description "'Red evaluates to Red, the <i>Symbol Name</i> of the symbol named ``Red''") (:description "When the <i>Lisp Reader</i> encounters a Symbol for the first time, it <i>interns</i> (creates) this symbol in its internal <i>Symbol Table</i>."))) (:title "Why Symbols?" :bullet-points ((:description "Two references to \"MyBigLongString\" and \"MyBigLongString\" refer to different strings") (:description "'MySymbol and 'MySymbol are both represented by the same symbol") (:description "<i>eql</i> is the most basic equality function in Lisp, testing whether its arguments refer to the same actual <i>Object</i> (memory location), while <i>string-equal</i> compares two strings for equality, character-by-character.") (:description "Comparing symbols for equality is much faster than comparing strings, since simple <i>eql</i> can be used instead of <i>string-equal</i>" :examples ((:code (string-equal "Mybiglongstring" "Mybiglongstring") :return-value t) (:code (eql 'MySymbol 'MySymbol) :return-value t))) (:description "Symbols turn out to be a very useful concept, and one of the distinguishing features of the Lisp language.") (:description "More on this later"))) (:title "Lists" :bullet-points ((:description "Lists are fundamental to LISP - LISt Processing") (:description "Lists are zero or more elements enclosed by parentheses") (:description "You have to quote a literal list for it to be evaluated as such; otherwise Lisp will assume you are trying to call a function" :examples ((:code '(red green blue) :return-value (red green blue)))))) (:title "Lisp Programs" :bullet-points ((:description "Lisp programs are themselves Lists") (:description "It is very easy for Lisp programs to generate and execute Lisp code") (:description "This is NOT true of most other languages" :examples ((:code (defun hey-now () (print "Hey Now")) :return-value hey-now))))) (:title "Overview of Lists - Creation" :bullet-points ((:description "A literal list with single-quote (elements are <i>not</i> evaluated)" :examples ((:code '(this is a list) :return-value (this is a list)))) (:description "Using the ``List'' function (evaluates all arguments)" :examples ((:code (list '(+ 1 2) 'is (+ 1 2)) :return-value ((+ 1 2) is 3)))))) (:title "Simple List Operations" :bullet-points ((:description "first list" :examples ((:code (first '(a b c)) :return-value a))) (:description "second list" :examples ((:code (second '(a b c)) :return-value b))) (:description "third list" :examples ((:code (third '(a b c)) :return-value c))) (:description "rest list" :examples ((:code (rest '(a b c)) ;; ;;Corrected by Joost at TUD training. ;; :return-value (b c)))) (:description "nth idx list" :examples ((:code (nth 2 '(a b c)) :return-value c))))) (:title "The Empty List" :bullet-points ((:description "nil represents falsehood," :examples ((:code nil :return-value nil)) :suppress-end-dot? t) (:description "as well as the empty list." :examples ((:code (list) :return-value nil)) :suppress-end-dot? t) (:description "nil evaluates to itself"))) (:title "Testing for Listness" :bullet-points ((:description "listp item" :examples ((:code (listp '(pontiac cadillac chevrolet)) :return-value t) (:code (listp 99) :return-value nil))) (:description "nil represents FALSE" :examples ((:code (listp nil) :return-value "???"))))) (:title "Functions" :bullet-points ((:description "defun name arg-list forms" :examples ((:code (defun hey-now () (print "Hey Now")) :return-value hey-now) (:code (hey-now) :return-value "[prints] Hey Now") (:code (defun square(x) (* x x)) :return-value square) (:code (square 4) :return-value 16))))) (:title "Reading Lisp Code" :bullet-points ((:description "Read using indentation.") (:description "You can generally let your eyes skip over the parenthesis" :examples ((:code (defun my-first-lisp-fn () (list 'hello 'world)) :return-value my-first-lisp-fn))) (:description "Try to read the preceding example as: <pre> (defun my-first-lisp-fn ( )(list 'hello world) ) </pre>" :suppress-end-dot? t) (:description "Now try to read it as: <pre> defun my-first-lisp-fn () list 'hello 'world </pre>" :suppress-end-dot? t) (:description "Close all parentheses together on the line. Dangling parenthesis are generally frowned upon in finished code." :examples ((:code '(united-states (ohio (toledo) indiana michigan (detroit (rennaissance-center (200-tower (fifth-floor (suite-20)))))))))) (:description "Compare the above example to: <pre> '(united-states (ohio (toledo) indiana michigan (detroit (rennaissance-center (200-tower (fifth-floor (suite-20) ) ) ) ) ) )</pre>" :suppress-end-dot? t) (:description "(no need for these dangling parentheses)"))) (:title "Local Variables" :bullet-points ((:description "New local variables are bound (introduced) using Let.") (:description "<i>let variable-assignments body</i>" :examples ((:code (let ((quantity 20) (excess 10)) (+ quantity excess)) :return-value 30))))) (:title "Variable Assignment" :bullet-points ((:description "In Lisp we use setq instead of =, :=, etc." :examples ((:code (let ((quantity 20) (excess 10)) (setq quantity 30) (+ quantity excess)) :return-value 40))) (:description "Global variables can be set with defparameter and changed with setq." :examples ((:code (defparameter *todays-temp* 101.5) :return-value *todays-temp*) (:code (setq *todays-temp* 99) :return-value 99) (:code *todays-temp* :return-value 99))) (:description "It is a long-standing Lisp convention to use Asterisks (``*'') to signify Global Variables (parameters). This is convention only, and the Asterisks have no meaning to Lisp itself.") (:description "Setf is used to set ``locations'' resulting from a function call:" :examples ((:code (setq *operating-systems* (list "Solaris" "Windows" "FreeBSD" "iOS" "Android")) :return-value ("Solaris" "Windows" "FreeBSD" "iOS" "Android")) (:code (setf (first *operating-systems*) "Linux") :return-value "Linux") (:code *operating-systems* :return-value ("Linux" "Windows" "FreeBSD" "iOS" "Android")))))) (:title "Iteration" :bullet-points ((:description "dolist, dotimes") (:description "<i>dolist (variable-name list &optional return-value)</i>" :examples ((:code (let ((result 0)) (dolist (elem '(4 5 6 7) result) (setq result (+ result elem)))) :return-value 22))) (:description "<i>dotimes (variable-name upper-limit &optional return-value)</i>" :examples ((:code (let ((result 1)) (dotimes (n 10 result) (setq result (+ result n)))) :return-value 46)))))))))
16,373
Common Lisp
.lisp
472
24.271186
126
0.545131
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0d4859b143fb9db8c1fceaa80f44970482a854768308ba23b6291f5d652bc212
36,224
[ -1 ]
36,225
solutions.lisp
lisp-mirror_gendl/documentation/training/g101/exercises/source/solutions.lisp
;; ;; Copyright 2002-2011, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) ;; ;; Exercises from Slide 3.14 ;; (defun dots (number) "Write an iterative version of a function which takes a number and prints that many dots. Example call: (dots 3) --> ... " (dotimes (n number) (princ "."))) (defun dots-r (number) "Write a recursive version of a function which takes a number and prints that many dots. Example call: (dots 3) --> ... " (when (plusp number) (princ ".") (dots-r (1- number)))) (defun nth-rest (n list) "Write a recursive function which returns the result of applying rest n times to list (equivalent to the Lisp function nthcdr). Example call: (nth-rest 2 '(a b c d e f)) --> (c d e f) " (if (zerop n) list (nth-rest (1- n) (rest list)))) (defun our-nth (n list) "Write a recursive function which returns the nth element of a list (equivalent to the Lisp function nth). Example call: (our-nth 2 '(a b c d e f)) --> c " (first (nth-rest n list))) (defun our-getf (plist keyword) "Write a recursive function our-getf plist keyword, which behaves as getf Example call: (our-getf '(:germany :berlin :england :london :finland :helsinki :norway :oslo :france :paris) :finland) --> :helsinki " (unless (and (listp plist) (evenp (length plist))) (error "~s is a malformed property list.~%" plist)) (when plist (if (eql (first plist) keyword) (second plist) (our-getf (rest (rest plist)) keyword)))) ;; ;; Bonus exercises from Slide 3.14 ;; (defun filter-in (function list) "Write a function which takes a function object and a list, and returns a new list containing all elements of the list for which the function returns non-nil (equivalent to the CL function remove-if-not). Example call: (filter-in #'listp '(hello (how are you) well (i am okay) but (a bit tired)) --> ((how are you)(i am okay)(a bit tired)) " (let ((result nil)) (dolist (element list (reverse result)) (when (funcall function element) (push element result))))) (defun position-filter (function list) "Write a function which takes a function and a list, and returns a new list containing all elements from list for which the function returns true when applied to that element's (zero-indexed) position in the list. Example call: (position-filter #'oddp '(a berse result)) (when (funcall function c d e f)) --> (b d f) " (let ((result nil) (count 0)) (dolist (element list (reverse result)) (when (funcall function count) (push element result)) (incf count)))) (defun set-difference-o (list1 list2) "Write a function which works just like set-difference, except it retains the ordering of elements in the first list. Example call: (set-difference-o '(a b c d e f) '(e d b)) --> (a c f) " (let ((result nil)) (dolist (element list1 (reverse result)) (unless (member element list2) (push element result))))) (defun intersection-o (list1 list2) "Write a function which works just like intersection, except it retains the ordering of elements in the first list. Example call: (intersection-o '(a b c d e f) '(e d b)) --> (b d e) " (let ((result nil)) (dolist (element list1 (reverse result)) (when (member element list2) (push element result))))) (defparameter *test-cases* `((nth-rest (2 (a b c d e f)) (c d e f)) (our-nth (2 (a b c d e f)) c) (our-getf ((:germany :berlin :england :london :finland :helsinki :norway :oslo :france :paris) :finland) :helsinki) (filter-in (,#'listp (hello (how are you) well (i am okay) but (a bit tired))) ((how are you)(i am okay)(a bit tired))) (position-filter (,#'oddp (a b c d e f)) (b d f)) (position-filter (,#'evenp (:germany :berlin :england :london :finland :helsinki :norway :oslo :france :paris)) (:germany :england :finland :norway :france)) (set-difference-o ((a b c d e f) (e d b)) (a c f)) (intersection-o ((a b c d e f) (e d b)) (b d e)))) (defun run-tests () (dolist (test-case *test-cases*) (let ((result (apply (symbol-function (first test-case)) (second test-case)))) (if (equalp result (third test-case)) (format t "~%Function `~s' passed on ~s~%" (first test-case) (second test-case)) (format t "~%!!!Function `~s' failed on ~s~% -- returned ~s when ~s was expected.~%~%" (first test-case) (second test-case) result (third test-case)))))) (defun set-difference-o* (list1 list2 &key (test #'eql)) "Write a function which works just like set-difference, except it retains the ordering of elements in the first list. Example call: (set-difference-o '(a b c d e f) '(e d b)) --> (a c f) " (let ((result nil)) (dolist (element list1 (reverse result)) (unless (member element list2 :test test) (push element result))))) ;; ;; Exercises from Slide 5.11 ;; (defun sort-numbers (number-list &key (ordering :ascending)) (safe-sort number-list (ecase ordering ((:ascending :up) #'<) ((:descending :down) #'>)))) (defun sort-pairs (pair-list &key (ordering :ascending) (sort-by :number)) (let ((comparison-function (ecase ordering ((:ascending :up) (ecase sort-by (:number #'<) (:string #'string<))) ((:descending :down) (ecase sort-by (:number #'>) (:string #'string>)))))) (safe-sort pair-list #'(lambda(pair-1 pair-2) (funcall comparison-function (if (or (and (eql sort-by :number) (numberp (first pair-1))) (and (eql sort-by :string) (stringp (first pair-1)))) (first pair-1) (second pair-1)) (if (or (and (eql sort-by :number) (numberp (first pair-2))) (and (eql sort-by :string) (stringp (first pair-2)))) (first pair-2) (second pair-2))))))) ;; ;; Exercises from Slide 6.10 ;; (defparameter *current-directory* (make-pathname :defaults *load-pathname* :name nil :type nil)) (defun read-plist (&key (pathname (merge-pathnames "capitals.sexp" *current-directory*))) (with-open-file (in pathname) (read in))) (defun lookup-capital () (let ((plist (read-plist))) (princ "Please Enter a Keyword: ") (let ((keyword (read))) ;;(getf plist keyword) (getf plist (make-keyword (string-downcase keyword))) ))) (in-package :gwl-user) (defun plist-to-table (plist) (with-cl-who-string () ((:table :border 1) (mapc #'(lambda(state capital) (htm (:tr (:td (str state)) (:td (str capital))))) (plist-keys plist) (plist-values plist))))) ;; ;; Call the above with (gwl-user::plist-to-table (read-plist)) ;; ;; ;; Exercises from Slide 8.4 ;; (in-package :gdl-user) (let ((values-ht (make-hash-table :size 100))) (defun factorial* (number) (or (gethash number values-ht) (setf (gethash number values-ht) (if (<= number 1) 1 (* number (factorial* (1- number))))))))
7,782
Common Lisp
.lisp
216
32.152778
96
0.663449
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
99814fb950e0199e53b4a39322b78bb680040122249004dd43e11167219d6833
36,225
[ -1 ]
36,226
skeleton.lisp
lisp-mirror_gendl/documentation/training/g101/exercises/source/skeleton.lisp
;; ;; Copyright 2002-2011, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) ;; ;; Exercises from Slide 3.14 ;; (defun dots (number) "Write an iterative version of a function which takes a number and prints that many dots. Example call: (dots 3) --> ... " ) (defun dots-r (number) "Write a recursive version of a function which takes a number and prints that many dots. Example call: (dots 3) --> ... " ) (defun nth-rest (n list) "Write a recursive function which returns the result of applying rest n times to list (equivalent to the Lisp function nthcdr). Example call: (nth-rest 2 '(a b c d e f)) --> (c d e f) " ) (defun our-nth (n list) "Write a recursive function which returns the nth element of a list (equivalent to the Lisp function nth). Example call: (our-nth 2 '(a b c d e f)) --> c " ) (defun our-getf (plist keyword) "Write a recursive function our-getf plist keyword, which behaves as getf Example call: (our-getf '(:germany :berlin :england :london :finland :helsinki :norway :oslo :france :paris) :finland) --> :helsinki " ) ;; ;; Bonus exercises from Slide 3.14 ;; (defun filter-in (function list) "Write a function which takes a function object and a list, and returns a new list containing all elements of the list for which the function returns non-nil (equivalent to the CL function remove-if-not). Example call: (filter-in #'listp '(hello (how are you) well (i am okay) but (a bit tired)) --> ((how are you)(i am okay)(a bit tired)) " ) (defun position-filter (function list) "Write a function which takes a function and a list, and returns a new list containing all elements from list for which the function returns true when applied to that element's (zero-indexed) position in the list. Example call: (position-filter #'oddp '(a b c d e f)) --> (b d f) " ) (defun set-difference-o (list1 list2) "Write a function which works just like set-difference, except it retains the ordering of elements in the first list. Example call: (set-difference-o '(a b c d e f) '(e d b)) --> (a c f) " ) (defun intersection-o (list1 list2) "Write a function which works just like intersection, except it retains the ordering of elements in the first list. Example call: (intersection-o '(a b c d e f) '(e d b)) --> (b d e) " ) (defparameter *test-cases* `((nth-rest (2 (a b c d e f)) (c d e f)) (our-nth (2 (a b c d e f)) c) (our-getf ((:germany :berlin :england :london :finland :helsinki :norway :oslo :france :paris) :finland) :helsinki) (filter-in (,#'listp (hello (how are you) well (i am okay) but (a bit tired))) ((how are you)(i am okay)(a bit tired))) (position-filter (,#'oddp (a b c d e f)) (b d f)) (position-filter (,#'evenp (:germany :berlin :england :london :finland :helsinki :norway :oslo :france :paris)) (:germany :england :finland :norway :france)) (set-difference-o ((a b c d e f) (e d b)) (a c f)) (intersection-o ((a b c d e f) (e d b)) (b d e)))) (defun run-tests () (dolist (test-case *test-cases*) (let ((result (apply (symbol-function (first test-case)) (second test-case)))) (if (equalp result (third test-case)) (format t "~%Function `~s' passed on ~s~%" (first test-case) (second test-case)) (format t "~%!!!Function `~s' failed on ~s~% -- returned ~s when ~s was expected.~%~%" (first test-case) (second test-case) result (third test-case))))))
4,384
Common Lisp
.lisp
125
31.584
88
0.687455
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b3da53aa18891c56ddfec493dad4d1a51833a07ce9b590bf1de99af31c687ba3
36,226
[ -1 ]
36,228
publish.lisp
lisp-mirror_gendl/documentation/training/g101/source/publish.lisp
(in-package :training-g101) (publish :path "/training-g101" :function #'(lambda(req ent) (gwl-make-object req ent "training-g101:assembly"))) (publish-directory :prefix "/g101/images/" :destination (format nil "~a" (translate-logical-pathname "~/genworks/gendl/documentation/training/g101/images/"))) (publish-directory :prefix "/g101/style/" :destination (format nil "~a" (translate-logical-pathname "~/genworks/gendl/documentation/training/g101/style/"))) (defun make! () (gwl:crawl "training-g101:assembly") (glisp:rsync "/tmp/sites/assembly/" "genworks.com:kitchen/downloads/training-g101/" :options (list "zav")))
676
Common Lisp
.lisp
13
46.615385
120
0.709428
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
dacefc98f9334c51f374dc445ab6cf3a53f9f374590cc188220a221bd890c50f
36,228
[ -1 ]
36,229
drilled-block.lisp
lisp-mirror_gendl/documentation/training/g105/examples/source/drilled-block.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) #+nil (defun dmapcar (function list) (dmapc function list) (mapcar function list)) #+nil (defun dmapc (function list) (let ((count -1)) (mapc #'(lambda () (bt:make-thread function :name (format nil "thread ~a from dmapcar" (incf count)))) list))) (eval-when (:compile-toplevel :load-toplevel :execute) (setq *compile-for-dgdl?* t)) (define-object dgdl-test (base-object) :input-slots ((length 10) (width 20) (height 30) (hole-radius 2 :settable) (hole-length 35) (quantity 2 :settable)) :computed-slots ((local-volumes (mapsend (list-elements (the local-drilled)) :volume)) (remote-volumes (mapsend (list-elements (the remote-drilled)) :volume))) :objects ( (remote-utils :type 'remote-object :remote-type 'remote-utils ;;:sequence (:size (the remote-drilled number-of-elements)) ;;:host (the (remote-drilled (the-child index)) host) ;;:port (the (remote-drilled (the-child index)) port) :slot-a "a" :host "seven" :port "9000" ) (local-drilled :type 'drilled-block :sequence (:size (the quantity)) :pass-down (hole-length hole-radius)) (remote-drilled :type 'remote-object :sequence (:size (the quantity)) :remote-type 'drilled-block :host "localhost" :port (+ (the-child index) 9001) ;;:port (if (oddp (the-child index)) 9001 9002) :pass-down (length width height hole-length hole-radius))) :functions ( (collect-volumes () ;;(&key remote?) #+nil (dmapcar #'(lambda(drilled-block) (the-object drilled-block volume)) (list-elements (if remote? (the remote-drilled) (the local-drilled))))) (set-hole-radius! (value) (the (set-slot! :hole-radius value))))) (define-object remote-utils () :input-slots (slot-a) :computed-slots ((slot-b (string-append (the slot-a) " and b"))) :functions ((clear-remotes () (clrhash gwl::*remote-objects-hash*)) (global-gc () (format t "Hey now!~%") (glisp:gc-full)))) (define-object drilled-block (base-object) :input-slots (length width height hole-radius hole-length (quantity 50 :settable)) :computed-slots ((volume (the result volume)) (c-of-g (the result center-of-gravity))) :objects ((result :type 'subtracted-solid :pass-down (brep other-brep)) (brep :type 'box-solid :display-controls (list :color :green)) (other-brep :type 'cylinder-solid :radius (the hole-radius) :length (the hole-length) :display-controls (list :color :green)))) (eval-when (:compile-toplevel :load-toplevel :execute) (setq *compile-for-dgdl?* nil))
3,578
Common Lisp
.lisp
104
29.971154
90
0.686112
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0e4e5fe1592af4496e5153d22bbdc1042890011ee9afb5afa7be9cfe067bcd4b
36,229
[ -1 ]
36,230
assembly.lisp
lisp-mirror_gendl/documentation/training/g105/slides/source/assembly.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g105) (define-object assembly (slide-show-node) :input-slots ((title "G105: Distributed GDL Quickstart") (slide-package (find-package :training-g105)) (image-base-url "slide-show-images/") (style-url "/slide-show-style/top.css")) :objects ( (:session-01 :type 'session-01) (:session-02 :type 'session-02) ))
1,234
Common Lisp
.lisp
32
35.96875
70
0.741744
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e45b2b3afc7704239070adaf478bd0cb7f7d5bc157ef3305c65ac0967a8badec
36,230
[ -1 ]
36,231
session-02.lisp
lisp-mirror_gendl/documentation/training/g105/slides/source/session-02.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g105) (define-object session-02 (slide-show-leaf) :computed-slots ((strings-for-display "dGDL with Surfaces and Solids") (slide-data `((:title "Currently works best in certain ways" :bullet-points ((:description "Examples:" :examples ((:define-object drilled-block)))))))))
1,183
Common Lisp
.lisp
28
40.035714
70
0.746295
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a02a5d230079127258f8826742a77bdf54abeb01e73b9f71aa8feb67208801b8
36,231
[ -1 ]
36,232
session-01.lisp
lisp-mirror_gendl/documentation/training/g105/slides/source/session-01.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g105) (define-object session-01 (slide-show-leaf) :computed-slots ((strings-for-display "Introduction to Distributed GDL") (slide-data `((:title "Goals for Distributed GDL" :bullet-points ((:description "Enable standard GDL message-passing communication between pairs of GDL runtime hosts") (:description "Provide a basis for convenient parallel processing using multiple hosts/cores") (:description "Reduce garbage collector load by decomposing 1 large memory heap into <i>n</i> smaller ones"))) (:title "Topics Covered in G105" :bullet-points ((:description "The remote-object primitive, overview") (:description "Remote-object syntax") (:description "Current dGDL Best Practices"))) (:title "The <tt>remote-object</tt> Primitive") (:title "<tt>remote-object</tt> syntax") (:title "Current dGDL Best Practices")))))
1,769
Common Lisp
.lisp
35
47.371429
115
0.746784
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3bfff0af92f1985fcfdc63041fb68f692e0c71eefb78760a861fed77f9dc72bd
36,232
[ -1 ]
36,233
package.lisp
lisp-mirror_gendl/documentation/training/g105/source/package.lisp
;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: user; Base: 10 -*- (in-package :gdl-user) (gwl:define-package :training-g105 (:use :slide-show) (:export #:assembly))
172
Common Lisp
.lisp
3
55.333333
76
0.668675
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2ecfb45c3ec417a06354c9b08d5af5b4fbce57c1507c8689327d77d2b335970b
36,233
[ -1 ]
36,235
ch2-examples.lisp
lisp-mirror_gendl/documentation/training/g102-tud/examples/source/ch2-examples.lisp
;; ;; Copyright 2012 Genworks International and the Delft University of ;; Technology ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (define-object empty-surface (base-object) ;; ;; Empty specs -- will replace with "real" built-in surface ;; later. ;; ) (define-object wing (empty-surface) :computed-slots ((b 30) (c-root 6) (c-tip 3) (c-avg (/ (+ (the c-root) (the c-tip)) 2)) (taper (/ (the c-tip) (the c-root))))) (define-object wing-with-input (empty-surface) :input-slots (b) :computed-slots ((c-root 6) (c-tip 3) (c-avg (/ (+ (the c-root) (the c-tip)) 2)) (taper (/ (the c-tip) (the c-root))) (S (* (the b) (the c-avg))) (A (/ (expt (the b) 2) (the S))))) (define-object wing-more-inputs (empty-surface) :input-slots ((b 20) (c-root 6 :settable) (c-tip 3 :settable)) :computed-slots ((c-avg (/ (+ (the c-root) (the c-tip)) 2)) (taper (/ (the c-tip) (the c-root))) (S (* (the b) (the c-avg))) (A (/ (expt (the b) 2) (the S))))) (define-object engine (cylinder) :input-slots (Tmax)) (define-object wing-with-engine (empty-surface) :input-slots ((Tmax 800) (b 20) (c-root 6 :settable) (c-tip 3 :settable)) :computed-slots ((c-avg (/ (+ (the c-root) (the c-tip)) 2)) (taper (/ (the c-tip) (the c-root))) (S (* (the b) (the c-avg))) (A (/ (expt (the b) 2) (the S)))) :objects ((engine :type 'engine :Tmax (the Tmax)))) (define-object wing-with-engines (empty-surface) :input-slots ((Tmax-list (list 1000 800 900 1200) :settable) (c-root 6 :settable) (c-tip 3 :settable) (b 20)) :computed-slots ((Tmax-total (sum-elements (the engines) (the-element Tmax))) (c-avg (/ (+ (the c-root) (the c-tip)) 2)) (taper (/ (the c-tip) (the c-root))) (S (* (the b) (the c-avg))) (A (/ (expt (the b) 2) (the S)))) :objects ((engines :type 'engine :sequence (:size (length (the Tmax-list))) :Tmax (nth (the-child index) (the Tmax-list))))) (define-object aircraft (base-object) :input-slots ((rho 0.73) (friction-coefficient 0.005)) :computed-slots ((Sw (+ (* (the right-wing S) 2) (* (the left-wing S) 2) (the fuselage Sw)))) :objects ((right-wing :type 'wing-with-tanks) (left-wing :type 'wing-with-tanks) (fuselage :type 'fuselage :d 5 :l 42)) :functions ((compute-friction-force (speed) (* (the friction-coefficient) 1/2 (the rho) (expt speed 2) (the Sw)))))
3,208
Common Lisp
.lisp
104
27.048077
70
0.625367
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7021788a7edd022f344c5313891086a6c4a3ef175278628e2907631c325cea08
36,235
[ -1 ]
36,236
primi-plane-5.lisp
lisp-mirror_gendl/documentation/training/g102-tud/examples/source/primi-plane-5.lisp
;; ;; Copyright 2012 Genworks International and the Delft University of ;; Technology ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (define-object primi-plane (base-object) :input-slots ((data-folder *data-folder*) (data-file-name "aircraft-3.dat") (points-file-name "NACA_0012.dat")) :computed-slots ((data-file-path (merge-pathnames (the data-file-name) (the data-folder))) (points-file-path (merge-pathnames (the points-file-name) (the data-folder))) (dihedral (the data wing-dihedral) :settable)) :hidden-objects ((data :type 'aircraft-data :parameters (with-open-file (in (the data-file-path)) (read in)) :points-data (with-open-file (in (the points-file-path)) (read in))) (canonical-profile :type 'profile-curve :points-data (the data points-data))) :objects ((wing-assy :type 'box-wings :c-root (the data wing-c-root) :c-tip (the data wing-c-tip) :span (the data wing-span) :root-center (translate (the center) :down (- (the fuselage radius) (half (the-child thickness))) :front (* 1/6 (the fuselage length))) :thickness (the data wing-thickness) :dihedral (the dihedral) :display-controls (list :color :green) :canonical-profile (the canonical-profile)) (tail-assy :type 'box-tail :c-root (the data tail-c-root) :c-tip (the data tail-c-tip) :span (the data tail-span) :root-center (translate (the center) :down (- (the fuselage radius) (half (the-child thickness))) :rear (- (half (the fuselage length)) (half (the-child c-root)))) :fin-root-center (translate (the-child root-center) :up (- (twice (the fuselage radius)) (half (the-child thickness)))) :thickness (the data tail-thickness) :dihedral (the data tail-dihedral) :fin-span (the data fin-span) :fin-c-root (the data fin-c-root) :fin-c-tip (the data fin-c-tip) :fin-thickness (the data fin-thickness) :display-controls (list :color :blue) :canonical-profile (the canonical-profile)) (fuselage :type 'cylinder-fuselage :d (the data fuselage-diameter) :l (the data fuselage-length) :display-controls (list :color :red)))) (define-object profile-curve (fitted-curve) :input-slots (points-data) :computed-slots ((point-coordinates (rest (rest (the points-data)))) (x-coords (plist-keys (the point-coordinates))) (y-coords (plist-values (the point-coordinates))) (x-max (most 'get-x (the points))) (x-min (least 'get-x (the points))) (chord (- (get-x (the x-max)) (get-x (the x-min)))) (y-max (most 'get-y (the points))) (y-min (least 'get-y (the points))) (max-thickness (- (get-y (the y-max)) (get-y (the y-min)))) (points (mapcar #'(lambda (x y) (make-point x y 0)) (the x-coords) (the y-coords))))) (define-object aircraft-data () :input-slots (wing-span wing-c-root wing-c-tip wing-thickness wing-dihedral Tmax rho C-of-F fuselage-diameter fuselage-length fuselage-cross-section-percents tail-span tail-c-root tail-c-tip tail-thickness tail-dihedral fin-span fin-c-root fin-c-tip fin-thickness points-data )) (define-object cylinder-fuselage (cylinder) :input-slots (d l) :computed-slots ((radius (half (the d))) (length (the l)))) (define-object box-wings (base-object) :input-slots (root-center span c-root c-tip thickness dihedral canonical-profile) :objects ((wings :type 'box-wing :sequence (:size 2) :root-point (the root-center) :side (ecase (the-child index) (0 :right) (1 :left)) :span (the span) :c-root (the c-root) :c-tip (the c-tip) :thickness (the thickness) :canonical-profile (the canonical-profile) ;; ;; Left wing will get a left-handed coordinate system and be a mirror of the right. ;; :orientation (let* ((hinge (the (face-normal-vector (ecase (the-child side) (:right :front) (:left :rear))))) (right (rotate-vector-d (the (face-normal-vector (the-child side))) (the dihedral) hinge))) (alignment :right right :top (cross-vectors hinge right) :front (the (face-normal-vector :front))))))) (define-object box-tail (box-wings) :input-slots (fin-span fin-c-root fin-c-tip fin-thickness fin-root-center) :objects ((fin :type 'box-wing :root-point (the fin-root-center) :span (the fin-span) :c-root (the fin-c-root) :c-tip (the fin-c-tip) :thickness (the fin-thickness) :orientation (alignment :right (the (face-normal-vector :top)) :top (the (face-normal-vector :left)))))) (define-object box-wing (box) :input-slots (root-point side span c-root c-tip thickness canonical-profile) :computed-slots ((width (the span)) (length (the c-root)) (height (the thickness)) (center (translate-along-vector (the root-point) (the (face-normal-vector :right)) (half (the width)) ))) :objects ((box :type 'box :hidden? t :display-controls (list :color :orange :transparency 0.7)) (root-profile :type 'boxed-curve :curve-in (the canonical-profile) :scale-y (/ (the thickness) (the canonical-profile max-thickness)) :scale-x (/ (the c-root) (the canonical-profile chord)) :center (the (edge-center :left :front)) :orientation (alignment :top (the (face-normal-vector :right)) :right (the (face-normal-vector :rear)) :rear (the (face-normal-vector :top)))) (tip-profile :type 'boxed-curve :curve-in (the canonical-profile) :scale-y (/ (the thickness) (the canonical-profile max-thickness)) :scale-x (/ (the c-tip) (the canonical-profile chord)) :center (translate (the (edge-center :right :front)) :rear (- (the c-root) (the c-tip))) :orientation (the root-profile orientation)) (loft :type 'lofted-surface :curves (list (the root-profile) (the tip-profile))))) ;; ;; For convenience, look for data folder two levels up, one level up, ;; and in same directory as source file. ;; (defparameter *data-folder* (or (probe-file (merge-pathnames "../../data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (probe-file (merge-pathnames "../data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (probe-file (merge-pathnames "data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (error "Your data folder is not there. Please make a data folder with aircraft and points data, two or one or zero directory levels up from the directory of this source file.~%")))
7,892
Common Lisp
.lisp
214
30.691589
86
0.643839
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b2b7d19f0e6d6250a45c96ecc587f16bdf654a822509a12337a9528ecdd30962
36,236
[ -1 ]
36,237
primi-plane-1.lisp
lisp-mirror_gendl/documentation/training/g102-tud/examples/source/primi-plane-1.lisp
;; ;; Copyright 2012 Genworks International and the Delft University of ;; Technology ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (define-object primi-plane (base-object) :computed-slots ((dihedral 10 :settable)) :objects ((wing-assy :type 'box-wings :c-root 6 :c-tip 3 :span 30 :root-center (translate (the center) :down (- (the fuselage radius) (half (the-child thickness))) :front (* 1/6 (the fuselage length))) :thickness 1 :dihedral (the dihedral) :display-controls (list :color :green)) (fuselage :type 'cylinder-fuselage :d 5 :l 42 :display-controls (list :color :red)))) (define-object cylinder-fuselage (cylinder) :input-slots (d l) :computed-slots ((radius (half (the d))) (length (the l)))) (define-object box-wings (base-object) :input-slots (root-center span c-root c-tip thickness dihedral) :objects ((wings :type 'box-wing :sequence (:size 2) :root-point (the root-center) :side (ecase (the-child index) (0 :right) (1 :left)) :span (the span) :c-root (the c-root) :c-tip (the c-tip) :thickness (the thickness) ;; ;; Left wing will get a left-handed coordinate system and be a mirror of the right. ;; :orientation (let* ((hinge (the (face-normal-vector (ecase (the-child side) (:right :front) (:left :rear))))) (right (rotate-vector-d (the (face-normal-vector (the-child side))) (the dihedral) hinge))) (alignment :right right :top (cross-vectors hinge right) :front (the (face-normal-vector :front))))))) (define-object box-wing (box) :input-slots (root-point side span c-root c-tip thickness) :computed-slots ((width (the span)) (length (the c-root)) (height (the thickness)) (center (translate-along-vector (the root-point) (the (face-normal-vector :right)) (half (the width)) ))) :objects ((box :type 'box :hidden? t :display-controls (list :color :orange :transparency 0.7))))
2,767
Common Lisp
.lisp
75
31.92
86
0.665167
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7f67e49583357df50f5d0a8e3aacfba95ee01f3ae4a431b3d4ee271f2bfe4a80
36,237
[ -1 ]
36,238
primi-plane-2.lisp
lisp-mirror_gendl/documentation/training/g102-tud/examples/source/primi-plane-2.lisp
;; ;; Copyright 2012 Genworks International and the Delft University of ;; Technology ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (define-object primi-plane (base-object) :input-slots ((data-folder *data-folder*) (data-file-name "aircraft-2.dat")) :computed-slots ((data-file-path (merge-pathnames (the data-file-name) (the data-folder))) (data-list (with-open-file (in (the data-file-path)) (read in))) (dihedral (the data wing-dihedral) :settable)) :objects ((data :type 'aircraft-data :parameters (the data-list)) (wing-assy :type 'box-wings :c-root (the data wing-c-root) :c-tip (the data wing-c-tip) :span (the data wing-span) :root-center (translate (the center) :down (- (the fuselage radius) (half (the-child thickness))) :front (* 1/6 (the fuselage length))) :thickness (the data wing-thickness) :dihedral (the dihedral) :display-controls (list :color :green)) (fuselage :type 'cylinder-fuselage :d (the data fuselage-diameter) :l (the data fuselage-length) :display-controls (list :color :red)))) (define-object aircraft-data () :input-slots (wing-span wing-c-root wing-c-tip wing-thickness wing-dihedral Tmax rho C-of-F fuselage-diameter fuselage-length fuselage-cross-section-percents tail-span tail-c-root tail-c-tip tail-thickness tail-dihedral fin-span fin-c-root fin-c-tip fin-thickness)) (define-object cylinder-fuselage (cylinder) :input-slots (d l) :computed-slots ((radius (half (the d))) (length (the l)))) (define-object box-wings (base-object) :input-slots (root-center span c-root c-tip thickness dihedral) :objects ((wings :type 'box-wing :sequence (:size 2) :root-point (the root-center) :side (ecase (the-child index) (0 :right) (1 :left)) :span (the span) :c-root (the c-root) :c-tip (the c-tip) :thickness (the thickness) ;; ;; Left wing will get a left-handed coordinate system and be a mirror of the right. ;; :orientation (let* ((hinge (the (face-normal-vector (ecase (the-child side) (:right :front) (:left :rear))))) (right (rotate-vector-d (the (face-normal-vector (the-child side))) (the dihedral) hinge))) (alignment :right right :top (cross-vectors hinge right) :front (the (face-normal-vector :front))))))) (define-object box-wing (box) :input-slots (root-point side span c-root c-tip thickness) :computed-slots ((width (the span)) (length (the c-root)) (height (the thickness)) (center (translate-along-vector (the root-point) (the (face-normal-vector :right)) (half (the width)) ))) :objects ((box :type 'box :hidden? t :display-controls (list :color :orange :transparency 0.7)))) ;; ;; For convenience, look for data folder two levels up, one level up, ;; and in same directory as source file. ;; (defparameter *data-folder* (or (probe-file (merge-pathnames "../../data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (probe-file (merge-pathnames "../data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (probe-file (merge-pathnames "data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (error "Your data folder is not there. Please make a data folder with aircraft and points data, two or one or zero directory levels up from the directory of this source file.~%")))
4,572
Common Lisp
.lisp
133
28.887218
86
0.656948
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4a3125b43ead1abea8435a5888efc491cbde977bc68ab0e9cf5e1b1ab5d3d674
36,238
[ -1 ]
36,239
ch3-examples.lisp
lisp-mirror_gendl/documentation/training/g102-tud/examples/source/ch3-examples.lisp
;; ;; Copyright 2012 Genworks International and the Delft University of ;; Technology ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (define-object single-box (base-object) :computed-slots ((length 10) (width 16.18) (height 3.2)) :objects ((box :type 'box :length (the length) :width (the width) :height (the height)))) (define-object single-box-trickle (base-object) :computed-slots ((length 10) (width 16.18) (height 3.2)) :objects ((box :type 'box))) (define-object five-boxes (base-object) :computed-slots ((length 9) (width 4) (height 1) (display-controls (list :line-thickness 2)) (box-width 1) (box-length 1) (box-height 1)) :objects ((middle :type 'box :length (the box-length) :width (the box-width) :height (the box-height)) (right-rear :type 'box :length (the box-length) :width (the box-width) :height (the box-height) :display-controls (append (the display-controls) (list :color :green-forest)) :center (translate (the center) :right (half (the width)) :rear (half (the length)))) (right-front :type 'box :length (the box-length) :width (the box-width) :height (the box-height) :display-controls (append (the display-controls) (list :color :green-lime)) :center (translate (the center) :right (half (the width)) :front (half (the length)))) (left-rear :type 'box :display-controls (append (the display-controls) (list :color :red-orange)) :length (the box-length) :width (the box-width) :height (the box-height) :center (translate (the center) :left (half (the width)) :rear (half (the length)))) (left-front :type 'box :display-controls (append (the display-controls) (list :color :scarlet)) :length (the box-length) :width (the box-width) :height (the box-height) :center (translate (the center) :left (half (the width)) :front (half (the length)))))) (define-object tilted-monolith (base-object) :input-slots ((length 9) (width 4) (height 1)) :objects ((monolith :type 'box) (tilted :type 'box :display-controls (list :color :red :line-thickness 2) :orientation (alignment :top (rotate-vector-d (the (face-normal-vector :top)) 45 (the (face-normal-vector :rear))) :rear (the (face-normal-vector :rear)))))) (define-object cylinder-sample (cylinder) :computed-slots ((display-controls (list :line-thickness 2 :color :pink-spicy)) (length 10) (radius 3) (number-of-sections 25))) (define-object cone-sample (cone) :computed-slots ((display-controls (list :line-thickness 2 :color :blue-neon :transparency 0.5 :shininess 0.8 :specular-color :white)) (length 10) (radius-1 2) (inner-radius-1 1) (radius-2 5) (number-of-sections 5) (inner-radius-2 3))) (define-object sphere-sample (sphere) :computed-slots ((radius 150) (number-of-vertical-sections 10) (number-of-horizontal-sections 10) (display-controls (list :line-thickness 2 :color :green-forest-medium)))) (define-object spherical-cap-sample (spherical-cap) :computed-slots ((base-radius 150) (cap-thickness 7) (axis-length (* (the base-radius) +phi+)) (number-of-vertical-sections 10) (number-of-horizontal-sections 10) (display-controls (list :line-thickness 2 :color :orchid-medium :transparency 0.5)))) (define-object torus-sample (torus) :computed-slots ((major-radius 150) (minor-radius 42) (draw-centerline-arc? t) (number-of-longitudinal-sections 10) (number-of-transverse-sections 10) (display-controls (list :line-thickness 2 :color :green-forest-medium)))) (define-object global-filleted-polygon-projection-sample (global-filleted-polygon-projection) :computed-slots ((display-controls (list :line-thickness 2 :color :blue-steel :transparency 0.3 :shininess 0.7 :spectral-color :white)) (default-radius 5) (projection-depth 5) (vertex-list (list (make-point 0 0 0) (make-point 10 10 0) (make-point 30 10 0) (make-point 40 0 0) (make-point 30 -10 0) (make-point 10 -10 0) (make-point 0 0 0))))) (define-object simple-curve (base-object) :input-slots ((control-points (list (make-point -2 0 0) (make-point -1 1 0) (make-point 1 1 0) (make-point 2 0 0)))) :objects ((curve :type 'b-spline-curve :control-points (the control-points)) (points :type 'points-display :points (the control-points)))) (define-object simple-curve-set (base-object) :input-slots ((control-points (list (make-point -2 0 0) (make-point -1 1 0) (make-point 1 1 0) (make-point 2 0 0)))) :objects ((curves :type 'b-spline-curve :sequence (:size 6) :degree (1+ (the-child index)) :control-points (the control-points)) (points :type 'points-display :points (the control-points)))) (define-object simple-surface (base-object) :input-slots ((control-points (list (list (make-point -2 0 -2) (make-point -1 1 -2) (make-point 1 1 -2) (make-point 2 0 -2)) (list (make-point -2 0 -1) (make-point -1 2 -1) (make-point 1 2 -1) (make-point 2 0 -1)) (list (make-point -2 0 1) (make-point -1 2 1) (make-point 1 2 1) (make-point 2 0 1)) (list (make-point -2 0 2) (make-point -1 1 2) (make-point 1 1 2) (make-point 2 0 2))))) :objects ((surface :type 'b-spline-surface :display-controls (list :color :blue :line-thickness 2 :bezier-points t) :control-points (the control-points)))) (define-object simple-surface-set (base-object) :input-slots ((control-points (list (list (make-point -2 0 -2) (make-point -1 1 -2) (make-point 1 1 -2) (make-point 2 0 -2)) (list (make-point -2 0 -1) (make-point -1 2 -1) (make-point 1 2 -1) (make-point 2 0 -1)) (list (make-point -2 0 1) (make-point -1 2 1) (make-point 1 2 1) (make-point 2 0 1)) (list (make-point -2 0 2) (make-point -1 1 2) (make-point 1 1 2) (make-point 2 0 2))))) :objects ((surfaces :type 'b-spline-surface :sequence (:size 6) :u-degree (1+ (the-child index)) :display-controls (list :color :blue :line-thickness 2 :bezier-points t) :control-points (the control-points)))) (define-object boxed-curves-example (base-object) :objects ((wavy :type 'b-spline-curve :control-points (list (make-point -2 0 0) (make-point -1 1 0) (make-point 1 1 0) (make-point 2 0 0) (make-point 3 0 00))) (translated :type 'boxed-curve :display-controls (list :color :red :line-thickness 2) :curve-in (the wavy) :center (translate (the center) :right 5)) (translated-rotated :type 'boxed-curve :display-controls (list :color :green :line-thickness 2) :curve-in (the translated) :orientation (alignment :rear (the (face-normal-vector :left)))) (mirrored :type 'boxed-curve :display-controls (list :color :blue :line-thickness 2) :curve-in (the wavy) :orientation (alignment :rear (the (face-normal-vector :front)) :right (the (face-normal-vector :right)) :top (the (face-normal-vector :top)))) (mirrored-2 :type 'boxed-curve :display-controls (list :color :orange :line-thickness 2) :curve-in (the translated) :orientation (alignment :rear (the (face-normal-vector :front)) :right (the (face-normal-vector :right)) :top (the (face-normal-vector :top)))) (mirrored-3 :type 'boxed-curve :display-controls (list :color :pink :line-thickness 2) :curve-in (the translated-rotated) :from-orientation (the orientation) :orientation (alignment :rear (the (face-normal-vector :rear)) :right (the (face-normal-vector :left)) :top (the (face-normal-vector :top)))))) (define-object box-cone-unite (base-object) :hidden-objects ((cone :type 'cone-solid :length 100 :radius-1 5 :radius-2 20) (box :type 'box-solid :length 50 :width 50 :height 50)) :objects ((united :type 'united-solid :display-controls (list :line-thickness 2 :color :red) :brep (the box) :other-brep (the cone)))) (define-object box-cone-subtract (base-object) :hidden-objects ((cone :type 'cone-solid :length 100 :radius-1 5 :radius-2 20) (box :type 'box-solid :length 50 :width 50 :height 50)) :objects ((subtracted :type 'subtracted-solid :display-controls (list :line-thickness 2 :color :green :transparency 0.3) :brep (the box) :other-brep (the cone)))) (define-object box-cone-intersect (base-object) :hidden-objects ((cone :type 'cone-solid :length 100 :radius-1 5 :radius-2 20) (box :type 'box-solid :length 50 :width 50 :height 50)) :objects ((intersect :type 'intersected-solid :display-controls (list :line-thickness 2 :color :blue) :brep (the box) :other-brep (the cone)))) (define-object airfoil (base-object) :input-slots ((control-points '(#(0.0 0.0 0.05) #(9.5 0.0 2.0) #(17.0 0.0 2.0) #(22.0 0.0 0.0) #(17.0 0.0 -2.0) #(9.5 0.0 -2.0) #(0.0 0.0 -0.05))) (number-of-profiles 5) (span 108)) :computed-slots ((profile-spacing (/ (the span) (1- (the number-of-profiles))))) :hidden-objects ((profile-curves :type 'boxed-curve :sequence (:size (the number-of-profiles)) :curve-in (the profile) :center (translate (the center) :rear (* (the-child index) (the profile-spacing)))) (bspline :type 'b-spline-curve :control-points (the control-points)) (trailing-edge-line :type 'linear-curve :start (the bspline start) :end (the bspline end)) (profile :type 'composed-curve :curves (list (the bspline) (the trailing-edge-line)))) :objects ((loft :type 'lofted-surface :synchronized? t :curves (list-elements (the profile-curves))))) (define-object merged-airfoil (base-object) :input-slots ((span 108)) :computed-slots ((chord (3d-distance (the airfoil (profile-curves 0) (point 0.5)) (the airfoil (profile-curves 0) start)))) :hidden-objects ((airfoil :type 'airfoil :span (the span)) (ends :type 'rectangular-surface :sequence (:size 2) :width (* (the chord) 2.5) :length (the-child width) :center (ecase (the-child index) (0 (translate (the airfoil profile-curves first start) :rear (* (the airfoil span) 0.05))) (1 (translate (the airfoil profile-curves last start) :front (* (the airfoil span) 0.05)))) :orientation (alignment :top (the (face-normal-vector :rear)))) (spar :type 'rectangular-surface :center (translate (midpoint (the airfoil (profile-curves 0) start) (the airfoil (profile-curves 0) (point 0.5))) :rear (half (the airfoil span))) :orientation (alignment :top (the (face-normal-vector :right)) :rear (the (face-normal-vector :top))) :length (* (the chord) 1.2) :width (* (the airfoil span) 1.2))) :objects ((merged :type 'merged-solid :brep (the airfoil loft) :make-manifold? t :other-brep (cons (the spar) (list-elements (the ends)))))) (define-object regioned-airfoil (base-object) :input-slots ((span 108)) :hidden-objects ((merged :type 'merged-airfoil :span (the span))) :objects ((regioned :type 'regioned-solid :display-controls (list :line-thickness 2) :brep (the merged merged)))) (in-package :gwl-user) ;; ;; This macro, with-htm, is being added to core GDL in the GWL package. ;; (eval-when (:compile-toplevel :load-toplevel :execute) (unless (fboundp 'with-htm) (defmacro with-htm (&body body) `(gwl:with-cl-who-string () ,@body)))) (define-object wing-surface-and-volume (base-ajax-sheet) :computed-slots ((main-sheet-body (with-htm (when *developing?* (str (the development-links))) (:h2 "Wing Area and Tank Volume") ((:table :border 1) (:tr (:th "Area") (:td (fmt "~3,3f" (the regioned-airfoil regioned brep area))) (dolist (region (list-elements (the regioned-airfoil regioned breps))) (htm (:tr (:th (fmt "Region ~a Volume" (the-object region index))) (:td (fmt "~3,3f" (the-object region volume))))))))))) :objects ((regioned-airfoil :type 'regioned-airfoil))) (define-object wing-surface-and-volume-ajax (base-ajax-sheet) :input-slots ((span-default 108)) :computed-slots ((main-sheet-body (with-htm (when *developing?* (str (the development-links))) (:center (:h2 "Wing Area and Tank Volume")) (str (the input-section main-div)) (str (the report-section main-div))))) :objects ((regioned-airfoil :type 'regioned-airfoil :span (the span value)) (span :type 'text-form-control :domain :number :default (the span-default) :prompt "Wing Span" :ajax-submit-on-change? t) (input-section :type 'sheet-section :inner-html (with-htm (:p (str (the span html-string))))) (report-section :type 'sheet-section :inner-html (with-htm ((:table :border 1) (:tr (:th "Area") (:td (fmt "~3,3f" (the regioned-airfoil regioned brep area))) (dolist (region (list-elements (the regioned-airfoil regioned breps))) (htm (:tr (:th (fmt "Region ~a Volume" (the-object region index))) (:td (fmt "~3,3f" (the-object region volume)))))))))))) (define-object wing-with-graphics (wing-surface-and-volume-ajax) :computed-slots ((use-raphael? t) (main-sheet-body (with-htm (when *developing?* (str (the development-links))) (when (and (the parent) (typep (the parent) 'several-wings)) (htm ((:a :href (the parent url)) "Back to Spans"))) (:h2 "Wing Area and Tank Volume") (:table (:tr (:td (str (the input-section main-div))) (:td (str (the report-section main-div))))) (:table (:tr (:td (str (the merged-viewport main-div))) (:td (str (the regioned-viewport main-div)))))))) :objects ((merged-viewport :type 'base-ajax-graphics-sheet :image-format-default :png :view-direction-default :trimetric :display-list-objects (list (the regioned-airfoil merged merged)) :length 300 :width 300) (regioned-viewport :type 'base-ajax-graphics-sheet :view-direction-default :trimetric :image-format-default :png :display-list-objects (list-elements (the regioned-airfoil regioned breps)) :length 300 :width 300))) (define-object several-wings (base-ajax-sheet) :input-slots ((span-defaults (list 98 108 118))) :computed-slots ((main-sheet-body (with-htm (:h2 "Wing Areas and Tank Volumes for several Wings") (:ul (dolist (wing (list-elements (the wings))) (htm (:li ((:a :href (the-object wing url)) (fmt "Wing with default span of ~a" (the-object wing span-default)))))))))) :objects ((wings :type 'wing-with-graphics :sequence (:size (length (the span-defaults))) :span-default (nth (the-child index) (the span-defaults))))) (define-object wing-drawing (base-drawing) :input-slots ((page-length (getf (getf *paper-size-plist* :a4) :height)) (page-width (getf (getf *paper-size-plist* :a4) :width))) :objects ((regioned-airfoil :type 'regioned-airfoil)) :hidden-objects ((merged-view :type 'base-view :border-box? t :width (half (the width)) :length (half (the length)) :center (translate (the (vertex :top :right :rear)) :left (half (the-child width)) :front (half (the-child length))) :projection-vector (getf *standard-views* :trimetric) :objects (list (the regioned-airfoil merged merged))) (top-view :type 'base-view :border-box? t :width (half (the width)) :length (half (the length)) :center (translate (the (vertex :top :left :front)) :right (half (the-child width)) :rear (half (the-child length))) :projection-vector (getf *standard-views* :top) :objects (list-elements (the regioned-airfoil regioned breps))) (tri-view :type 'base-view :border-box? t :width (half (the width)) :length (half (the length)) :center (translate (the (vertex :top :right :front)) :left (half (the-child width)) :rear (half (the-child length))) :projection-vector (getf *standard-views* :trimetric) :objects (list-elements (the regioned-airfoil regioned breps))))) (define-object wing-drawing-with-dimension (wing-drawing) :objects ((span-dimension :type 'vertical-dimension :start-point (the regioned-airfoil regioned (breps 0) bounding-bbox (vertex :top :left :front)) :end-point (the regioned-airfoil regioned (breps 0) bounding-bbox (vertex :top :left :rear)) :flip-leaders? t :character-size 1.5) (top-view :type 'base-view :objects (cons (the span-dimension) (list-elements (the regioned-airfoil regioned breps)))))) (define-object wing-drawing-with-typeset-block (wing-drawing-with-dimension) :objects ((text :type 'wing-drawing-typeset-block :regioned (the regioned-airfoil regioned)) (text-view :type 'base-view :objects (list (the text)) :length (half (the length)) :width (half (the width)) :center (translate (the (vertex :top :left :rear)) :right (half (the-child width)) :front (half (the-child length)))))) (define-object wing-drawing-typeset-block (typeset-block) :input-slots (regioned) :functions ((content () (typeset:compile-text () (typeset:vspace 5) (typeset:table (:col-widths (list 180 175) ) (typeset:row () (typeset:cell () (typeset:paragraph (:font "Courier" :font-size 25) (typeset:put-string "Area"))) (typeset:cell () (typeset:paragraph (:font "Courier" :font-size 25) (typeset:put-string (format nil "~5,3f" (the regioned brep area)))))) (dolist (region (list-elements (the regioned breps))) (typeset:row () (typeset:cell () (typeset:paragraph (:font "Courier" :font-size 25) (typeset:put-string (format nil "Region ~a Volume" (the-object region index))))) (typeset:cell () (typeset:paragraph (:font "Courier" :font-size 25) (typeset:put-string (format nil "~3,3f" (the-object region volume)))))))))))) (define-object wing-drawing-with-output (wing-drawing-with-typeset-block) :functions ((pdf-out! () (let ((output-path (merge-pathnames "wing.pdf" (user-homedir-pathname)))) (with-format (pdf output-path :page-length (the page-length) :page-width (the page-width)) (write-the cad-output)) output-path)) (png-out! () (let ((output-path (merge-pathnames "wing.png" (user-homedir-pathname)))) (with-format (png output-path :page-length (the page-length) :page-width (the page-width)) (write-the cad-output)) output-path)))) (define-object wing-with-restore (wing-with-graphics) :objects ((restore-button :type 'button-form-control :label "Restore!" :onclick (the (gdl-ajax-call :function-key :restore-defaults! :bashee (the span)))) (input-section :type 'sheet-section :inner-html (with-htm (:p (str (the restore-button html-string))) (:p (str (the span html-string))))) )) (define-object wing-with-iges-download (wing-with-graphics) :computed-slots ((pdf-url (let ((url (glisp:replace-regexp (the url) "index\\.html" "wing-drawing.pdf"))) (publish :path url :function #'(lambda(req ent) (with-http-response (req ent) (with-http-body (req ent) (with-format (pdf (request-reply-stream req)) (write-the drawing cad-output)))))) url)) (iges-url (let ((url (glisp:replace-regexp (the url) "index\\.html" "wing-regions.iges"))) (publish :path url :function #'(lambda(req ent) (with-http-response (req ent) (with-http-body (req ent) (with-format (iges (request-reply-stream req)) (write-the regioned-airfoil cad-output-tree)))))) url)) (main-sheet-body (with-htm (when *developing?* (str (the development-links))) (when (and (the parent) (typep (the parent) 'several-wings)) (htm ((:a :href (the parent url)) "Back to Spans"))) (:h2 "Wing Area and Tank Volume") (:table (:tr (:td (str (the input-section main-div))) (:td (str (the report-section main-div))))) (:p ((:a :href (the pdf-url)) "Download PDF File")) (:p ((:a :href (the iges-url)) "Download Iges File")) (:table (:tr (:td (str (the merged-viewport main-div))) (:td (str (the regioned-viewport main-div)))))))) :objects ((drawing :type 'wing-drawing-with-input-airfoil :regioned-airfoil (the regioned-airfoil)))) (define-object wing-drawing-with-input-airfoil (wing-drawing-with-typeset-block) :input-slots (regioned-airfoil)) (define-object wing-with-submit (wing-with-graphics) :objects ((span :type 'text-form-control :domain :number :default (the span-default) :prompt "Wing Span" :ajax-submit-on-change? nil) (restore-button :type 'button-form-control :label "Restore!" :onclick (the (gdl-ajax-call :function-key :restore-defaults! :bashee (the span)))) (submit-button :type 'button-form-control :label "Submit" :onclick (the (gdl-ajax-call :form-controls (list (the span))))) (input-section :type 'sheet-section :inner-html (with-htm (:p (str (the span html-string))) (:p (str (the submit-button html-string))) (:p (str (the restore-button html-string))))) )) (define-object wing-with-iges-and-step (base-object) :objects ((regioned-airfoil :type 'regioned-airfoil)) :functions ((iges-out! () (with-format (iges (merge-pathnames "wing-regions.iges" (user-homedir-pathname))) (write-the regioned-airfoil regioned cad-output-tree))) (step-out! () (with-format (step (merge-pathnames "wing-regions.step" (user-homedir-pathname))) (dolist (brep (list-elements (the regioned-airfoil regioned breps))) (write-the-object brep cad-output)))) (native-out! () (with-format (native (merge-pathnames "wing-regions.iwp" (user-homedir-pathname))) (write-the regioned-airfoil regioned cad-output-tree))))) (define-object wing-readers (base-object) :input-slots ((base-path (merge-pathnames "wing-regions" (user-homedir-pathname)))) :objects ((iges-reader :type 'iges-reader :file-name (make-pathname :type "iges" :defaults (the base-path))) (step-reader :type 'step-reader :file-name (make-pathname :type "step" :defaults (the base-path))) (native-reader :type 'native-reader :file-name (make-pathname :type "iwp" :defaults (the base-path))))) (define-object merged-3rds (base-object) :computed-slots ((chord (3d-distance (the airfoil (profile-curves 0) (point 0.5)) (the airfoil (profile-curves 0) start)))) :hidden-objects ((airfoil :type 'airfoil) (ends :type 'rectangular-surface :sequence (:size 2) :width (* (the chord) 2.5) :length (the-child width) :center (ecase (the-child index) (0 (translate (the airfoil profile-curves first start) :rear (* (the airfoil span) 0.05))) (1 (translate (the airfoil profile-curves last start) :front (* (the airfoil span) 0.05)))) :orientation (alignment :top (the (face-normal-vector :rear)))) (spar :type 'rectangular-surface :sequence (:size 2) :center (translate (midpoint (the airfoil (profile-curves 0) start) (the airfoil (profile-curves 0) (point 0.5))) :rear (half (the airfoil span)) :left (ecase (the-child index) (0 (* 1/6 (the chord))) (1 (- (* 1/6 (the chord)))))) :orientation (alignment :top (the (face-normal-vector :right)) :rear (the (face-normal-vector :top))) :length (* (the chord) 1.2) :width (* (the airfoil span) 1.2))) :objects ((merged :type 'merged-solid :brep (the airfoil loft) :other-brep (append (list-elements (the spar)) (list-elements (the ends)))))) (define-object regioned-3rds (base-object) :objects ((merged :type 'merged-3rds)) :objects ((regioned :type 'regioned-solid :display-controls (list :line-thickness 2) :brep (the merged merged))))
32,935
Common Lisp
.lisp
757
28.568032
83
0.502481
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2a9842c805013b00f9c4b105656609c12effa784daa0199aa01b976b20350c6a
36,239
[ -1 ]
36,240
primi-plane-6.lisp
lisp-mirror_gendl/documentation/training/g102-tud/examples/source/primi-plane-6.lisp
;; ;; Copyright 2012 Genworks International and the Delft University of ;; Technology ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (define-object primi-plane (base-object) :input-slots ((data-folder *data-folder*) (data-file-name "aircraft-3.dat") (points-file-name "NACA_0012.dat")) :computed-slots ((data-file-path (merge-pathnames (the data-file-name) (the data-folder))) (points-file-path (merge-pathnames (the points-file-name) (the data-folder))) (dihedral (the data wing-dihedral) :settable)) :hidden-objects ((data :type 'aircraft-data :parameters (with-open-file (in (the data-file-path)) (read in)) :points-data (with-open-file (in (the points-file-path)) (read in))) (canonical-profile :type 'profile-curve :points-data (the data points-data))) :objects ((wing-assy :type 'box-wings :c-root (the data wing-c-root) :c-tip (the data wing-c-tip) :span (the data wing-span) :root-center (translate (the center) :down (- (the fuselage radius) (half (the-child thickness))) :front (* 1/6 (the fuselage length))) :thickness (the data wing-thickness) :dihedral (the dihedral) :display-controls (list :color :green) :canonical-profile (the canonical-profile)) (tail-assy :type 'box-tail :c-root (the data tail-c-root) :c-tip (the data tail-c-tip) :span (the data tail-span) :root-center (translate (the center) :down (- (the fuselage radius) (half (the-child thickness))) :rear (- (half (the fuselage length)) (the-child c-root))) :fin-root-center (translate (the-child root-center) :up (* 4/3 (the fuselage radius))) :thickness (the data tail-thickness) :dihedral (the data tail-dihedral) :fin-span (the data fin-span) :fin-c-root (the data fin-c-root) :fin-c-tip (the data fin-c-tip) :fin-thickness (the data fin-thickness) :display-controls (list :color :blue) :canonical-profile (the canonical-profile)) (fuselage :type 'cylinder-fuselage :d (the data fuselage-diameter) :l (the data fuselage-length) :cross-section-percents (the data fuselage-cross-section-percents) :display-controls (list :color :red)))) (define-object profile-curve (fitted-curve) :input-slots (points-data) :computed-slots ((point-coordinates (rest (rest (the points-data)))) (x-coords (plist-keys (the point-coordinates))) (y-coords (plist-values (the point-coordinates))) (x-max (most 'get-x (the points))) (x-min (least 'get-x (the points))) (chord (- (get-x (the x-max)) (get-x (the x-min)))) (y-max (most 'get-y (the points))) (y-min (least 'get-y (the points))) (max-thickness (- (get-y (the y-max)) (get-y (the y-min)))) (points (mapcar #'(lambda (x y) (make-point x y 0)) (the x-coords) (the y-coords))))) (define-object aircraft-data () :input-slots (wing-span wing-c-root wing-c-tip wing-thickness wing-dihedral Tmax rho C-of-F fuselage-diameter fuselage-length fuselage-cross-section-percents tail-span tail-c-root tail-c-tip tail-thickness tail-dihedral fin-span fin-c-root fin-c-tip fin-thickness points-data )) (define-object cylinder-fuselage (cylinder) :input-slots (d l cross-section-percents) :computed-slots ((radius (half (the d))) (length (the l)) (section-offset-percentages (plist-keys (the cross-section-percents))) (section-centers (let ((nose-point (the (face-center :front)))) (mapcar #'(lambda(percentage) (translate nose-point :rear (* percentage 1/100 (the length)))) (the section-offset-percentages)))) (section-diameter-percentages (plist-values (the cross-section-percents))) (section-radii (mapcar #'(lambda(percentage) (* 1/100 percentage (the radius))) (the section-diameter-percentages)))) :hidden-objects ((section-curves :type 'arc-curve :sequence (:size (length (the section-centers))) :center (nth (the-child index) (the section-centers)) :radius (nth (the-child index) (the section-radii)) :orientation (alignment :top (the (face-normal-vector :rear))))) :objects ((floor-plane :type 'rectangular-surface :display-controls (list :color :black) :width (* (the radius) 4) :length (* (the length) 3/2)) (merged :type 'merged-solid :brep (the floor-plane) :other-brep (the loft) :make-manifold? t) (regioned :type 'regioned-solid :display-controls nil :brep (the merged)) (loft :type 'lofted-surface :end-caps-on-brep? t :curves (list-elements (the section-curves))))) (define-object box-wings (base-object) :input-slots (root-center span c-root c-tip thickness dihedral canonical-profile) :objects ((wings :type 'box-wing :sequence (:size 2) :root-point (the root-center) :side (ecase (the-child index) (0 :right) (1 :left)) :span (the span) :c-root (the c-root) :c-tip (the c-tip) :thickness (the thickness) :canonical-profile (the canonical-profile) ;; ;; Left wing will get a left-handed coordinate system and be a mirror of the right. ;; :orientation (let* ((hinge (the (face-normal-vector (ecase (the-child side) (:right :front) (:left :rear))))) (right (rotate-vector-d (the (face-normal-vector (the-child side))) (the dihedral) hinge))) (alignment :right right :top (cross-vectors hinge right) :front (the (face-normal-vector :front))))))) (define-object box-tail (box-wings) :input-slots (fin-span fin-c-root fin-c-tip fin-thickness fin-root-center) :objects ((fin :type 'box-wing :root-point (the fin-root-center) :span (the fin-span) :c-root (the fin-c-root) :c-tip (the fin-c-tip) :thickness (the fin-thickness) :orientation (alignment :right (the (face-normal-vector :top)) :top (the (face-normal-vector :left)))))) (define-object box-wing (box) :input-slots (root-point side span c-root c-tip thickness canonical-profile) :computed-slots ((width (the span)) (length (the c-root)) (height (the thickness)) (center (translate-along-vector (the root-point) (the (face-normal-vector :right)) (half (the width)) ))) :hidden-objects ((box :type 'box :display-controls (list :color :orange :transparency 0.7)) (root-profile :type 'boxed-curve :curve-in (the canonical-profile) :scale-y (/ (the thickness) (the canonical-profile max-thickness)) :scale-x (/ (the c-root) (the canonical-profile chord)) :center (the (edge-center :left :front)) :orientation (alignment :top (the (face-normal-vector :right)) :right (the (face-normal-vector :rear)) :rear (the (face-normal-vector :top)))) (tip-profile :type 'boxed-curve :curve-in (the canonical-profile) :scale-y (/ (the thickness) (the canonical-profile max-thickness)) :scale-x (/ (the c-tip) (the canonical-profile chord)) :center (translate (the (edge-center :right :front)) :rear (- (the c-root) (the c-tip))) :orientation (the root-profile orientation))) :objects ((loft :type 'lofted-surface :end-caps-on-brep? t :curves (list (the root-profile) (the tip-profile))))) ;; ;; For convenience, look for data folder two levels up, one level up, ;; and in same directory as source file. ;; (defparameter *data-folder* (let* ((source-pathname #+allegro excl:*source-pathname* #+lispworks dspec:*source-pathname* ;; in future: (glisp:source-pathname) ) (base-path (make-pathname :name nil :type nil :defaults source-pathname ;; in future: (glisp:source-pathname) ))) (or (probe-file (merge-pathnames "../../data/" base-path)) (probe-file (merge-pathnames "../data/" base-path)) (probe-file (merge-pathnames "data/" base-path)) (error "Your data folder is not there. Please make a data folder with aircraft and points data, two or one or zero directory levels up from the directory of this source file.~%"))))
9,151
Common Lisp
.lisp
242
31.855372
86
0.652882
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
52ea6d4a110213d2feac3eb618c1b62e3c9b619aa98381b82b2567807638777b
36,240
[ -1 ]
36,241
primi-plane-4.lisp
lisp-mirror_gendl/documentation/training/g102-tud/examples/source/primi-plane-4.lisp
;; ;; Copyright 2012 Genworks International and the Delft University of ;; Technology ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (define-object primi-plane (base-object) :input-slots ((data-folder *data-folder*) (data-file-name "aircraft-3.dat") (points-file-name "NACA_0012.dat")) :computed-slots ((data-file-path (merge-pathnames (the data-file-name) (the data-folder))) (points-file-path (merge-pathnames (the points-file-name) (the data-folder))) (dihedral (the data wing-dihedral) :settable)) :hidden-objects ((data :type 'aircraft-data :parameters (with-open-file (in (the data-file-path)) (read in)) :points-data (with-open-file (in (the points-file-path)) (read in))) (canonical-profile :type 'profile-curve :points-data (the data points-data))) :objects ((wing-assy :type 'box-wings :c-root (the data wing-c-root) :c-tip (the data wing-c-tip) :span (the data wing-span) :root-center (translate (the center) :down (- (the fuselage radius) (half (the-child thickness))) :front (* 1/6 (the fuselage length))) :thickness (the data wing-thickness) :dihedral (the dihedral) :display-controls (list :color :green) :canonical-profile (the canonical-profile)) (fuselage :type 'cylinder-fuselage :d (the data fuselage-diameter) :l (the data fuselage-length) :display-controls (list :color :red)))) (define-object profile-curve (fitted-curve) :input-slots (points-data) :computed-slots ((point-coordinates (rest (rest (the points-data)))) (x-coords (plist-keys (the point-coordinates))) (y-coords (plist-values (the point-coordinates))) (x-max (most 'get-x (the points))) (x-min (least 'get-x (the points))) (chord (- (get-x (the x-max)) (get-x (the x-min)))) (y-max (most 'get-y (the points))) (y-min (least 'get-y (the points))) (max-thickness (- (get-y (the y-max)) (get-y (the y-min)))) (points (mapcar #'(lambda (x y) (make-point x y 0)) (the x-coords) (the y-coords))))) (define-object aircraft-data () :input-slots (wing-span wing-c-root wing-c-tip wing-thickness wing-dihedral Tmax rho C-of-F fuselage-diameter fuselage-length fuselage-cross-section-percents tail-span tail-c-root tail-c-tip tail-thickness tail-dihedral fin-span fin-c-root fin-c-tip fin-thickness points-data )) (define-object cylinder-fuselage (cylinder) :input-slots (d l) :computed-slots ((radius (half (the d))) (length (the l)))) (define-object box-wings (base-object) :input-slots (root-center span c-root c-tip thickness dihedral canonical-profile) :objects ((wings :type 'box-wing :sequence (:size 2) :root-point (the root-center) :side (ecase (the-child index) (0 :right) (1 :left)) :span (the span) :c-root (the c-root) :c-tip (the c-tip) :thickness (the thickness) :canonical-profile (the canonical-profile) ;; ;; Left wing will get a left-handed coordinate system and be a mirror of the right. ;; :orientation (let* ((hinge (the (face-normal-vector (ecase (the-child side) (:right :front) (:left :rear))))) (right (rotate-vector-d (the (face-normal-vector (the-child side))) (the dihedral) hinge))) (alignment :right right :top (cross-vectors hinge right) :front (the (face-normal-vector :front))))))) (define-object box-wing (box) :input-slots (root-point side span c-root c-tip thickness canonical-profile) :computed-slots ((width (the span)) (length (the c-root)) (height (the thickness)) (center (translate-along-vector (the root-point) (the (face-normal-vector :right)) (half (the width)) ))) :objects ((box :type 'box :hidden? t :display-controls (list :color :orange :transparency 0.7)) (root-profile :type 'boxed-curve :curve-in (the canonical-profile) :scale-y (/ (the thickness) (the canonical-profile max-thickness)) :scale-x (/ (the c-root) (the canonical-profile chord)) :center (the (edge-center :left :front)) :orientation (alignment :top (the (face-normal-vector :right)) :right (the (face-normal-vector :rear)) :rear (the (face-normal-vector :top)))) (tip-profile :type 'boxed-curve :curve-in (the canonical-profile) :scale-y (/ (the thickness) (the canonical-profile max-thickness)) :scale-x (/ (the c-tip) (the canonical-profile chord)) :center (translate (the (edge-center :right :front)) :rear (- (the c-root) (the c-tip))) :orientation (the root-profile orientation)) (loft :type 'lofted-surface :curves (list (the root-profile) (the tip-profile))))) ;; ;; For convenience, look for data folder two levels up, one level up, ;; and in same directory as source file. ;; (defparameter *data-folder* (or (probe-file (merge-pathnames "../../data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (probe-file (merge-pathnames "../data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (probe-file (merge-pathnames "data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (error "Your data folder is not there. Please make a data folder with aircraft and points data, two or one or zero directory levels up from the directory of this source file.~%")))
6,624
Common Lisp
.lisp
182
30.39011
86
0.646781
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
449b13efc1f08191c6e59e85ca3405ac7b4d5ed1faf72b0290d3f19368befaf6
36,241
[ -1 ]
36,242
ch2-solutions.lisp
lisp-mirror_gendl/documentation/training/g102-tud/examples/source/ch2-solutions.lisp
;; ;; Copyright 2012 Genworks International and the Delft University of ;; Technology ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ATTENTION!!! ;; ATTENTION!!! DO NOT LOOK AT THIS SOURCE UNTIL YOU TRY THE EXERCISES YOURSELF!!! ;; ATTENTION!!! ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :gdl-user) (define-object fuselage (cylinder) :input-slots ((d 6) (l 40)) :computed-slots ((A (* 1/4 pi (expt (the d) 2))) (C (* pi (the d))) (V (* (the A) (the l))) (Sw (* (the C) (the l))) (slenderness (/ (the l) (the d))))) (define-object fuel-tank () :input-slots (l w h) :computed-slots ((volume (* (the l) (the w) (the h))))) (define-object wing-with-tanks (empty-surface) :input-slots ((Tmax-list (list 1000 800 900 1200) :settable) (b 30) (c-root 6 :settable) (c-tip 3 :settable) (tank-data (list (list :w 4 :l 3.5 :h .3 ) (list :w 2 :l 2.5 :h .2 ) (list :w 1.5 :l 2 :h 0.15))) (other-inputs "...")) :computed-slots ((Tmax-total (sum-elements (the engines) (the-element Tmax))) (tank-volume (sum-elements (the fuel-tanks) (the-element volume))) (c-avg (/ (+ (the c-root) (the c-tip)) 2)) (taper (/ (the c-tip) (the c-root))) (S (* (the b) (the c-avg))) (A (/ (expt (the b) 2) (the S)))) :objects ((engines :type 'engine :sequence (:size (length (the Tmax-list))) :Tmax (nth (the-child index) (the Tmax-list))) (fuel-tanks :type 'fuel-tank :sequence (:size (length (the tank-data))) :l (getf (nth (the-child index) (the tank-data)) :l) :w (getf (nth (the-child index) (the tank-data)) :w) :h (getf (nth (the-child index) (the tank-data)) :h)))) (define-object aircraft-with-lift (base-object) :input-slots ((rho 0.73) (friction-coefficient 0.005)) :computed-slots ((Sw (+ (* (the right-wing S) 2) (* (the left-wing S) 2) (the fuselage Sw)))) :objects ((right-wing :type 'wing-with-tanks) (left-wing :type 'wing-with-tanks) (fuselage :type 'fuselage)) :functions ((compute-friction-force (speed) (* (the friction-coefficient) 1/2 (the rho) (expt speed 2) (the Sw))) (compute-lift-force (speed CL) (* CL 1/2 (the rho) (expt speed 2) (+ (the right-wing S) (the left-wing S))))))
3,060
Common Lisp
.lisp
91
29.56044
82
0.612308
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
81dc6d9d8ebc10f51e18ebd4fbadfca57cf03a1f93a1cbb1278c8f19b3a9dc58
36,242
[ -1 ]
36,243
primi-plane-3.lisp
lisp-mirror_gendl/documentation/training/g102-tud/examples/source/primi-plane-3.lisp
;; ;; Copyright 2012 Genworks International and the Delft University of ;; Technology ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (define-object primi-plane (base-object) :input-slots ((data-folder *data-folder*) (data-file-name "aircraft-3.dat") (points-file-name "NACA_0012.dat")) :computed-slots ((data-file-path (merge-pathnames (the data-file-name) (the data-folder))) (points-file-path (merge-pathnames (the points-file-name) (the data-folder))) (dihedral (the data wing-dihedral) :settable)) :objects ((data :type 'aircraft-data :parameters (with-open-file (in (the data-file-path)) (read in)) :points-data (with-open-file (in (the points-file-path)) (read in))) (canonical-profile :type 'profile-curve :points-data (the data points-data)) (wing-assy :type 'box-wings :c-root (the data wing-c-root) :c-tip (the data wing-c-tip) :span (the data wing-span) :root-center (translate (the center) :down (- (the fuselage radius) (half (the-child thickness))) :front (* 1/6 (the fuselage length))) :thickness (the data wing-thickness) :dihedral (the dihedral) :display-controls (list :color :green)) (fuselage :type 'cylinder-fuselage :d (the data fuselage-diameter) :l (the data fuselage-length) :display-controls (list :color :red)))) (define-object profile-curve (fitted-curve) :input-slots (points-data) :computed-slots ((point-coordinates (rest (rest (the points-data)))) (x-coords (plist-keys (the point-coordinates))) (y-coords (plist-values (the point-coordinates))) (points (mapcar #'(lambda (x y) (make-point x y 0)) (the x-coords) (the y-coords))))) (define-object aircraft-data () :input-slots (wing-span wing-c-root wing-c-tip wing-thickness wing-dihedral Tmax rho C-of-F fuselage-diameter fuselage-length fuselage-cross-section-percents tail-span tail-c-root tail-c-tip tail-thickness tail-dihedral fin-span fin-c-root fin-c-tip fin-thickness points-data )) (define-object cylinder-fuselage (cylinder) :input-slots (d l) :computed-slots ((radius (half (the d))) (length (the l)))) (define-object box-wings (base-object) :input-slots (root-center span c-root c-tip thickness dihedral) :objects ((wings :type 'box-wing :sequence (:size 2) :root-point (the root-center) :side (ecase (the-child index) (0 :right) (1 :left)) :span (the span) :c-root (the c-root) :c-tip (the c-tip) :thickness (the thickness) ;; ;; Left wing will get a left-handed coordinate system and be a mirror of the right. ;; :orientation (let* ((hinge (the (face-normal-vector (ecase (the-child side) (:right :front) (:left :rear))))) (right (rotate-vector-d (the (face-normal-vector (the-child side))) (the dihedral) hinge))) (alignment :right right :top (cross-vectors hinge right) :front (the (face-normal-vector :front))))))) (define-object box-wing (box) :input-slots (root-point side span c-root c-tip thickness) :computed-slots ((width (the span)) (length (the c-root)) (height (the thickness)) (center (translate-along-vector (the root-point) (the (face-normal-vector :right)) (half (the width)) ))) :objects ((box :type 'box :hidden? t :display-controls (list :color :orange :transparency 0.7)))) ;; ;; For convenience, look for data folder two levels up, one level up, ;; and in same directory as source file. ;; (defparameter *data-folder* (or (probe-file (merge-pathnames "../../data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (probe-file (merge-pathnames "../data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (probe-file (merge-pathnames "data/" (make-pathname :name nil :type nil :defaults excl:*source-pathname* ;; in future: (glisp:source-pathname) ))) (error "Your data folder is not there. Please make a data folder with aircraft and points data, two or one or zero directory levels up from the directory of this source file.~%")))
5,252
Common Lisp
.lisp
150
29.28
86
0.654282
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
027caddb9da820aec88a2628736d58c1a1501caac2139075b265c97d5aa18352
36,243
[ -1 ]
36,244
ch3.lisp
lisp-mirror_gendl/documentation/training/g102-tud/slides/source/ch3.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102-tud) (define-object geometry (slide-show-leaf) :computed-slots ((strings-for-display "Geometry") (slide-data `((:title ,(with-htm ((:span :class "gdl-object-def" :style "font-size: 1em") "base-object")) :bullet-points ((:description ,(with-htm "You can mix in " ((:span :class "gdl-object-def") "base-object") " to get a basic coordinate system.")) (:description ,(with-htm "This includes input messages for " ((:span :class "gdl-message-name") "length") ", " ((:span :class "gdl-message-name") "width") ", " ((:span :class "gdl-message-name") "height") ", " ((:span :class "gdl-message-name") "center") ", and " ((:span :class "gdl-message-name") "orientation") ", " "and GDL functions for each " ((:span :class "gdl-message-name") "vertex") ", " ((:span :class "gdl-message-name") "face-center") ", " ((:span :class "gdl-message-name") "edge-center") ", " "and " ((:span :class "gdl-message-name") "face-normal-vector."))))) (:title ,(with-htm ((:span :class "gdl-object-def" :style "font-size: 1em;") "box")) :bullet-points ((:description ,(with-htm "All GDL geometry primitives mix in (inherit from) " ((:span :class "gdl-object-def") "base-object") " Perhaps the simplest geometry primitive is " ((:span :class "gdl-object-def") "box") ".") :examples ((:define-object gdl-user::single-box :include-sample-drawing? t))) (:description ,(with-htm "Typically, your the actual geometry will end up in leaf-level child objects, while higher-level nodes might be simple " ((:span :class "gdl-object-def") "base-object") "s acting as containers.")))) (:title ,(with-htm ((:span :class "gdl-section-keyword" :style "font-size: 1em;") "trickle-down-slots")) :bullet-points ((:description ,(with-htm ((:span :class "gdl-message-name") "length") ", " ((:span :class "gdl-message-name") "width") ", " ((:span :class "gdl-message-name") "height") ", " ((:span :class "gdl-message-name") "center") ", " ((:span :class "gdl-message-name") "orientation") " are actually defined as " ((:span :class "gdl-section-keyword") ":trickle-down-slots") " in " ((:span :class "gdl-object-def") "base-object") ", which means that you do not have to pass these down (they \"trickle down\" automatically). So the previous example is equivalent to:") :examples ((:define-object gdl-user::single-box-trickle))) (:description ,(with-htm "If you are ever tempted to define your own " ((:span :class "gdl-section-keyword") "trickle-down-slots") " in your definitions, do it with caution; they can make it difficult to trace where values are coming from.")))) (:title "Working with points and vectors" :bullet-points ( (:description "3D points are represented in GDL as a <i>vector</i> of three numbers") (:description "You can make a point from three numbers with the <span class=gdl-operator>make-point</span> operator:" :examples ((:code (make-point 0 0 0) :return-value #(0.0 0.0 0.0)) (:code (make-point 10 20 30) :return-value #(10.0 20.0 30.0)))) (:description "Or by translating another point along a vector with <span class=gdl-operator>translate-along-vector</span> operator:" :examples ((:code (translate-along-vector (make-point 0 0 0) (make-vector 0 0 1) 10) :return-value #(0.0 0.0 10.0)) (:code (translate-along-vector (make-point 0 0 0) (make-vector 1 1 1) 1) :return-value #(0.5773502691896258 0.5773502691896258 0.5773502691896258)))) (:description "Other operators for manipulating points and vectors include <span class=gdl-operator>rotate-point</span>, <span class=gdl-operator>rotate-point-d</span>, <span class=gdl-operator>rotate-vector</span>, <span class=gdl-operator>rotate-vector-d</span>, <span class=gdl-operator>subtract-vectors</span>, <span class=gdl-operator>add-vectors</span>, and <span class=gdl-operator>scalar*vector</span>") (:description "See the Documentation tab in Tasty for full reference on these operators"))) (:title "Positioning a child object with <span class=gdl-message-name style=\"font-size: 1em;\">center</span>" :bullet-points ((:description "Objects can be positioned by specifying their <span class=gdl-message-name>center</span>, which is expected to be a <i>3D point</i>.") (:description "Within the context of an object definition, you can simply use the <span class=gdl-operator>translate</span> operator to translate a point by a distance in any of the six direction keywords: <span class=lisp-code>:right</span>, <span class=lisp-code>:left</span>, <span class=lisp-code>:rear</span>, <span class=lisp-code>:front</span>, <span class=lisp-code>:up</span>, and <span class=lisp-code>:down</span>") (:description "<span class=lisp-code>:right</span> is the X axis, <span class=lisp-code>:rear</span> is the Y axis, and <span class=lisp-code>:top</span> is the Z axis:" :examples ((:define-object gdl-user::five-boxes :include-sample-drawing? t))))) (:title "Orienting a child object with <span class=gdl-message-name style=\"font-size: 1em;\">orientation</span>" :bullet-points ((:description "You can use the <span class=gdl-operator>alignment</span> operator to produce a 3x3 orthonormal transformation matrix suitable for use as an <span class=gdl-message-name>orientation</span>.") (:description "Alignment takes up to three direction keywords (the third is only necessary if you want to force a left-handed coordinate system):" :examples ((:define-object gdl-user::tilted-monolith :include-sample-drawing? t))))) (:title "<i>Exercises</i> 4 and 5" :bullet-points ((:description "4. Make a twisty tower of boxes, resembling the image below:" :image-url "tower-ex.png") (:description "5. Make a traditional brick wall, with alternating rows shifted by 1/2 brick width, and flush sides (you need half-width bricks on the ends in alternate rows)."))) (:title "Other Wireframe Objects" :bullet-points ((:description "Many mechanical and layout applications do not require surfaces and solids") (:description "Built-in wireframe objects are in the <span class=lisp-code>:geom-base</span> package") (:description "Wireframe primitives do not support generic intersections, mass properties, parametric evaluation") (:description "Common wireframe primitives:" :examples ((:define-object gdl-user::cylinder-sample :include-sample-drawing? t) (:define-object gdl-user::cone-sample :include-sample-drawing? t) (:define-object gdl-user::sphere-sample :include-sample-drawing? t) (:define-object gdl-user::spherical-cap-sample :include-sample-drawing? t) (:define-object gdl-user::torus-sample :include-sample-drawing? t) (:define-object gdl-user::global-filleted-polygon-projection-sample :include-sample-drawing? t))) (:description "See full documentation for these in <a href=http://localhost:9000/yadd>YADD</a> (also available as <i>Documentation</i> tab in tasty)"))) (:title "Curves, Surfaces, and Solids" :bullet-points ((:description ":surf package supports NURBS curves and surfaces") (:description "If you can understand Curves then you can understand Surfaces") (:description "The NURBS Book (Piegl, Tiller) is the definitive reference") (:description "<b>N</b>on-<b>U</b>niform <b>R</b>ational <b>B</b>-<b>S</b>plines") (:description "<b>Non-Uniform</b> means a curve (or surface) can have a knot vector (or knot grid) which induces non-uniform parameterization.") (:description "<b>Rational</b> means a curve or surface can have weighting factors (one per control point) to affect the geometry. Weights are required to represent analytics (e.g. arcs (spheres)) using NURBS.") (:description "<b>B-Splines</b> (short for \"Basis Splines\"), means the curve (surface) is controlled by a list (grid) of 3D control-points.") (:description "Sometimes the control-points are combined with the weights and written as 4D points."))) (:title "Curve data structure in GDL" :bullet-points ((:description "NURBS curves data structure contains four pieces of data: <ol> <li><span class=gdl-message-name>control-points</span> (list of 3D points)</li> <li><span class=gdl-message-name>weights</span> (list of numbers, one per control point)</li> <li><span class=gdl-message-name>degree</span> (a single integer, degree of polynomial curve function)</li> <li><span class=gdl-message-name>knot-vector</span> (list of numbers representing parameter values, affect the shape of the curve)</li> </ol>"))) (:title "<span class=gdl-object-def style=\"font-size: 1em;\">b-spline-curve</span>" :bullet-points ((:description "defines a NURBS curve which accepts the four components of curve data directly" :examples ((:define-object gdl-user::simple-curve :include-sample-drawing? t))) (:description "Note that with default degree (3) and default weights and knot vector, this is a Cubic Bezier curve and interpolates (i.e. touches) its end points."))) (:title "Probing the curve object" :bullet-points ((:description "Basic NURBS curve input components" :examples ((:code (make-self 'simple-curve) :return-value "#<simple-curve @ #x740cbf22>") (:code (the curve control-points) :return-value (#(-2.0 0.0 0.0) #(-1.0 1.0 0.0) #(1.0 1.0 0.0) #(2.0 0.0 0.0))) (:code (the curve knot-vector) :return-value (0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0)) (:code (the curve weights) :return-value (1.0 1.0 1.0 1.0)) (:code (the curve degree) :return-value 3))) (:description "Pulling info from the curve" :examples ((:code (the curve total-length) :return-value 4.381037353487265) (:code (the curve u-min) :return-value 0.0) (:code (the curve u-max) :return-value 1.0) (:code (the curve (tangent 0.5)) :return-value #(1.0 0.0 0.0)) (:code (the curve (radius-of-curvature 0.5)) :return-value 3.375))))) (:title "<i>Exercise</i> 6" :bullet-points ((:description "Change the <span class=gdl-object-def>simple-curve</span> definition from Slide 3.11 to contain a sequence of four (4) child curves. Each child should receive a <span class=lisp-code>:degree</span> passed in which is one greater than its index number (i.e. the degree will start with 1 and work up to 4). Then use an instance of this definition to answer the following questions: <ol type = \"a\"> <li>Is it even possible to produce a curve with the given control points and with each of the specified degree values? <li>Ask each child for its <span class=gdl-message-name>total-length</span>. <li>Does the total-length increase or decrease with an increasing degree? </ol>"))) (:title "Surface data structure in GDL" :bullet-points ((:description "NURBS surface data structure contains six pieces of data: <ol> <li><span class=gdl-message-name>control-points</span> --- list of lists of 3D points</li> <li><span class=gdl-message-name>weights</span> --- list of lists of numbers, one per control point</li> <li><span class=gdl-message-name>u-degree</span> --- a single integer, degree of polynomial curve function in u direction</li> <li><span class=gdl-message-name>v-degree</span> --- a single integer, degree of polynomial curve function in v direction</li> <li><span class=gdl-message-name>u-knot-vector</span> --- list of numbers representing parameter values in u direction, affect the shape of the surface in u direction</li> <li><span class=gdl-message-name>v-knot-vector</span> --- list of numbers representing parameter values in v direction, affect the shape of the surface in v direction</li> </ol>"))) (:title "<span class=gdl-object-def>b-spline-surface</span>" :bullet-points ((:description "defines a NURBS surface which accepts the six components of surface data directly" :examples ((:define-object gdl-user::simple-surface :include-sample-drawing? t))) (:description "Note that with default degree (3) and default weights and knot vector, this is a Cubic Bezier surface and interpolates (i.e. touches) its control points at its corners."))) (:title "Probing the surface object" :bullet-points ((:description "Basic NURBS surface input components" :examples ((:code (make-self 'simple-surface) :return-value "#<simple-surface @ #x740cbf22>") (:code (the surface control-points) :return-value ((#(-2.0 0.0 -2.0) #(-1.0 1.0 -2.0) #(1.0 1.0 -2.0) #(2.0 0.0 -2.0)) (#(-2.0 0.0 -1.0) #(-1.0 2.0 -1.0) #(1.0 2.0 -1.0) #(2.0 0.0 -1.0)) (#(-2.0 0.0 1.0) #(-1.0 2.0 1.0) #(1.0 2.0 1.0) #(2.0 0.0 1.0)) (#(-2.0 0.0 2.0) #(-1.0 1.0 2.0) #(1.0 1.0 2.0) #(2.0 0.0 2.0)))) (:code (the surface u-knot-vector) :return-value (0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0)) (:code (the surface v-knot-vector) :return-value (0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0)) (:code (the surface weights) :return-value ((1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0))) (:code (the surface u-degree) :return-value 3) (:code (the surface v-degree) :return-value 3))))) (:title "Probing the surface object (cont'd)" :bullet-points ((:description "Pulling info from the surface" :examples ((:code (the surface area) :return-value 19.745028077271574) (:code (the surface u-min) :return-value 0.0) (:code (the surface u-max) :return-value 1.0) (:code (the surface v-min) :return-value 0.0) (:code (the surface v-max) :return-value 1.0) (:code (the surface (normal 0.5 0.5)) :return-value #(0.0 -1.0 0.0)) (:code (the surface u-iso-curves first) :return-value "#<curve @ #x74d5050a>"))))) (:title "<i>Exercise</i> 7" :bullet-points ((:description "Change the <span class=gdl-object-def>simple-surface</span> definition from Slide 3.15 to contain a sequence of four (4) child surfaces. Each child should receive a <span class=gdl-message-name>:u-degree</span> passed in which is one greater than its index number (i.e. the <span class=gdl-message-name>u-degree</span> will start with 1 and work up to 4). Then use an instance of this definition to answer the following questions: <ol type = \"a\"> <li>Is it even possible to produce a surface with the given control points and with each of the specified <span class=gdl-message-name>u-degree</span> values? <li>Ask each child for its <span class=gdl-message-name>area</span>. <li>Does the area increase or decrease with an increasing <span class=gdl-message-name>u-degree</span>?</ol>"))) (:title "Transforming Curves and Surfaces" :bullet-points ((:description "Pure curves, surfaces and solids get their position, shape, and dimensions directly from global control points") (:description "They <i>do not</i> respect the reference-box from <span class=gdl-object-def>base-object</span>.") (:description "For transforming curves and surfaces, you can use <span class=gdl-object-def>boxed-curve</span> and <span class=gdl-object-def>boxed-surface</span>.") (:description "Example translated, rotated, and mirrored:" :examples ((:define-object gdl-user::boxed-curves-example :include-sample-drawing? t :projection-direction :top ))))) (:title "<i>Exercise</i> 8" :bullet-points ((:description "Use the <span class=gdl-message-name>wavy</span> object from the previous example for this exercise. <ol type=\"a\"> <li>Check the reference documentation for <span class=gdl-object-def>boxed-curve</span> and see how to add a scale in X, Y, and Z axes.</li> <li>Add a sequence of three (3) <span class=gdl-object-def>boxed-curve</span>s to the <span class=gdl-object-def>boxed-curves-example</span> and scale them by a factor of 2 in the X, Y, and Z axes, respectively. </li> <li>How does the scaling in each direction affect the <span class=gdl-message-name>total-length</span>?</li> </ol> "))) (:title "Solids and Booleans" :bullet-points ((:description "Solids are one or more regions bounded by trimmed surfaces (faces).") (:description "Connected faces form a shell.") (:description "A closed shell forms a region.") (:description "A <i>brep</i> can have zero or more shells and one or more regions") (:description "There is always the <i>infinite</i> region (all of space outside the brep)."))) (:title "Boolean operations" :bullet-points ((:description "Brep operations are <i>closed</i> - breps in, and you always get one or more breps out") (:description "United-solids example" :examples ((:define-object gdl-user::box-cone-unite :include-sample-drawing? t :side-by-side "united.png"))) (:description "Subtracted-solids example" :examples ((:define-object gdl-user::box-cone-subtract :include-sample-drawing? t :side-by-side "subtract.png"))) (:description "Intersected-solids example" :examples ((:define-object gdl-user::box-cone-intersect :include-sample-drawing? t ))))) (:title "Non-manifold Breps" :bullet-points ((:description "In <i>manifold</i> Breps, all edges are shared by exactly two faces") (:description "GDL can handle <i>non-manifold</i> Breps, which can be useful as construction geometry") (:description "The <i>merge</i> operation can join together surfaces and faces into a solid, and get rid of extra pieces of faces, in one operation." :examples ((:define-object gdl-user::airfoil :include-sample-drawing? t) (:define-object gdl-user::merged-airfoil :include-sample-drawing? t ) (:define-object gdl-user::regioned-airfoil :include-sample-drawing? t))) (:description "Note that breps only display their edges by default. You can set <span class=lisp-code>*brep-isos-default*</span> to adjust this:" :examples ((:code *brep-isos-default* :return-value nil) (:code (setq *brep-isos-default* (list :n-u 8 :n-v 8)) :return-value (:n-u 8 :n-v 8)))))) (:title "<i>Exercise 9</i>" :bullet-points ((:description "Add a second spar two-thirds (2/3) of the way from trailing edge to leading edge, and move the first spar to one-third (1/3) of the way. Your <span class=gdl-object-def>regioned-solid</span> should now have three regions instead of two.") (:description "Check that the total <span class=gdl-message-name>volume</span> of the three regions equals the total of the two regions with the single spar.") (:description "Scale the profiles with 10% decreasing chord length as they go from root to tip.") (:description "Re-orient the spars so they follow the leading edge and trailing edge, respectively.") (:description "Make a <span class=gdl-section-keyword>computed-slot</span> which holds the interior (i.e. middle) region (call this the \"fuel tank\"). Add a slot which computes its volume.")))))))
23,311
Common Lisp
.lisp
470
38.993617
140
0.607918
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5f701ac28accb5558dac2eeee271e20415f81bde929538064222154115fa4c57
36,244
[ -1 ]
36,245
ch2.lisp
lisp-mirror_gendl/documentation/training/g102-tud/slides/source/ch2.lisp
;; ;; Copyright 2012 Genworks International and the Delft University of ;; Technology ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :training-g102-tud) (defmacro with-htm (&body body) `(with-cl-who-string () ,@body)) (define-object assembly (slide-show-node) :input-slots ((title "G102: GDL Quickstart") (slide-package (find-package :training-g102-tud)) (image-base-url "/g102-tud/images/") (images-path *images-path*) (style-url "/static/gwl/style/top.css")) :objects ((introduction :type 'introduction) (objects :type 'objects) (geometry :type 'geometry) )) (define-object introduction (slide-show-leaf) :computed-slots ((strings-for-display "Introduction") (slide-data `((:title "Goals" :bullet-points ((:description "Spark an interest in the Generative KBE approach for solving Engineering and other problems") (:description "Provide Theoretical Knowledge combined with Hands-on Experience") (:description ,(with-htm "Help you develop the Judgement to know when Generative KBE (and Genworks" ((:font :size "-2") (:sup "&reg;")) " GDL in particular) will be Appropriate for a given problem")))) (:title "Topics Covered in G102" :bullet-points ((:description ,(with-cl-who-string () "Objects in GDL and the " ((:span :class "gdl-operator") "define-object") " operator" (:ul (:li "Debugging (basic)") (:li "Inspection & Visualization (tasty)")))) (:description ,(with-output-to-string (ss) (html-stream ss "Geometry and Coordinate Systems" (:ul (:li "Points") (:li "Curves") (:li "Surfaces") (:li "Solids"))))) (:description "Custom User Interfaces (optional)") (:description "Interacting with the Outside World") (:description "Debugging and Performance (detailed)"))) (:title "What is Common Lisp?" :bullet-points ((:description ,(with-htm "A " ((:a :href "http://en.wikipedia.org/wiki/Common_Lisp_HyperSpec" :target "supplemental") "Specification") " for a " ((:a :href "https://www.google.com/search?client=ubuntu&channel=fs&q=dynamic+languages&ie=utf-8&oe=utf-8" :target "supplemental") "Dynamic") ", Object-oriented Language and Runtime environment")) (:description "Industry-standard dialect of the Lisp language family") (:description "Available in several Commercial and Open-Source implementations"))) (:title "What is GDL?" :bullet-points ((:description "A Declarative language environment embedded in Common Lisp") (:description "A technology enabling you to define problems and their solutions using an intuitive, straightforward structure") (:description "A Compiler and Runtime engine enabling Model creation and Application deployment") (:description ,(with-htm "A cross-platform " ((:a :href "http://en.wikipedia.org/wiki/Web_application_framework") "web application framework") " seamlessly embedded in the core language")) (:description ,(with-htm "Kernel and basic geometry freely available through the " ((:a :href "http://www.gnu.org/licenses/agpl-3.0.html" :target "_fresh_") "AGPL") "-licensed " ((:a :href "http://github.com/genworks/gendl" :target "_fresh_") "Gendl" ((:font :size "-2") (:sup "&#0153;"))) " Project. Proprietary (closed-source) application distribution, Geometry Kernel, etc, available through commercial Genworks" ((:font :size "-2") (:sup "&reg;")) " GDL package.")))) (:title "A Path of Discovery: GDL as a Learning Tool" :bullet-points ((:description "Humans learn best through Action and Discovery") (:description "Applies to learning GDL itself") (:description "Applies to learning about your own engineering domain"))))))) (define-object objects (slide-show-leaf) :computed-slots ((strings-for-display "Functions and Objects") (slide-data `((:title "Function" :bullet-points ((:description "A machine which accepts some Input then yields a defined Output" :image-url "function-machine.jpg" :image-caption "A Function Machine <small><i>(image from http://wbadvies.nl)</i></small>") )) (:title "Calling Functions in Common Lisp" :bullet-points ((:description "Function Call is expressed as a List expression (a.k.a. \"Symbolic EXPression\" or \"S-exp\")") (:description "Function name first, then arguments, separated by spaces") (:description ,(with-htm "For example, we feed " ((:span :class :lisp-code) "2") " and " ((:span :class :lisp-code) "2") " into the function " ((:span :class :lisp-code) "+") " to yield the result which is " ((:span :class :lisp-code) "4")) :examples ((:code (+ 2 2) :return-value 4))) (:description ,(with-htm "The multiply function (" ((:span :class :lisp-code) "*") ") applied to " ((:span :class :lisp-code) "3") " and " ((:span :class :lisp-code) "3")) :examples ((:code (* 3 3) :return-value 9))) (:description ,(with-htm "The " ((:span :class :lisp-code) "string-append") " function applied to three strings") :examples ((:code (string-append "hey" " " "now") :return-value "hey now"))))) (:title "Defining and Using Custom Functions in Common Lisp" :bullet-points ((:description ,(with-htm "Use the operator " ((:span :class :lisp-code) "defun") ", followed by name, argument list, and body.") :examples ((:code (defun square (number) (* number number)) :return-value square))) (:description "Now you can call it just like any other function" :examples ((:code (square 3) :return-value 9))))) (:title "Function as Object" :bullet-points ((:description ,(with-htm ((:table :border 1) (:tr ((:th :width 0.5) :br) ((:th :width 0.5 ) "Function (Common Lisp)") ((:th :width 0.5 ) "Object (GDL)")) (:tr (:td (:b "Typical Purpose")) ((:td :bgcolor (lookup-color :aquamarine :format :hex) :colspan 2 :align :center) (:ol (:li "Accept some " (:i "inputs")) (:li "possibly performs some " (:i "side-effects")) (:li "compute one or more " (:i "outputs"))))) (:tr (:td (:b "How to Use")) ((:td :bgcolor (lookup-color :thistle :format :hex)) "You call it by name, by evaluating a Lisp expression") ((:td :bgcolor (lookup-color :aquamarine :format :hex)) (:ol (:li "You create or retrieve an " (:i "object")) (:li "You send " (:i "messages") " to the object to get the outputs")))) (:tr (:td (:b "How to Define")) ((:td :bgcolor (lookup-color :thistle :format :hex)) (:pre (:b ((:span :class :lisp-code) "(defun " (:i "name (arguments) body)"))))) ((:td :bgcolor (lookup-color :aquamarine :format :hex)) (:code (:pre (:b ((:span :class :gdl-object-def) ((:span :class :gdl-operator) "(define-object ") ((:span :class :gdl-object-def) (:i "name ")) (:i "(mixins) " :br "&nbsp;&nbsp;" ((:span :class :lisp-code) "specifications)")))))))) (:tr (:td (:b "How to Decompose Complexity")) ((:td :bgcolor (lookup-color :thistle :format :hex)) "Call other function definitions from within a function definition") ((:td :bgcolor (lookup-color :aquamarine :format :hex)) (:ol (:li "<i>Inherit</i> <i>slots</i> from other definitions using <i>mixins</i>") (:li "Include <i>objects</i> of other types inside an object")))))) :suppress-end-dot? t))) (:title "Empty Surface Mixin" :bullet-points ((:description "Define an Empty Surface (we will use real built-in surface later)" :examples ((:define-object gdl-user::empty-surface))) (:description ,(with-htm ((:span :class "gdl-operator") "define-object") " - main operator used in GDL to create definitions.")) (:description ,(with-htm ((:span :class "gdl-object-def") "empty-surface") " - Name of our new definition.")) (:description ,(with-htm ((:span :class "gdl-object-def") "base-object") " - Name of single mixin (should be pre-defined).")))) (:title "Basic Wing Skeleton" :bullet-points ((:description "Define a wing with initial slots, mixes in empty surface to start with" :image-url "uml-2-5.png" :examples ((:define-object gdl-user::wing))) (:description ,(with-htm ((:span :class "gdl-object-def") "wing") " - our new definition name.")) (:description ,(with-htm ((:span :class "gdl-object-def") "empty-surface") " - Name of single mixin (which we already defined).")) (:description ,(with-htm ((:span :class "gdl-section-keyword") ":computed-slots") " - constant and computed values which can be \"answered\" by instances of this definition.")) (:description ,(with-htm (:small (:i "Example code is " ((:a :href "https://github.com/genworks/gendl/blob/master/documentation/training/g102-tud/examples/source/ch2-examples.lisp" :target "_fresh") "here") ". Press \"Raw\" for raw downloadable form.")))))) (:title ,(with-cl-who-string () ((:span :class "gdl-section-keyword") ":computed-slots")) :bullet-points ((:description "Each slot is given as its own list:" :code ((:examples ((:define-object gdl-user::wing))))) (:description ,(with-cl-who-string () "Each list contains " (:ul (:li "its name --- e.g. " ((:span :class "gdl-message-name") "c-avg") " is a name, and") (:li "its expression --- e.g. " ((:span :class "gdl-object-def") "(/ (+ (the c-root) (the c-tip)) 2)") " is an expression.")))) (:description "The expression can be either a constant value, or an expression which computes a value on-demand."))) (:title "Making and Using Objects on Command-line (REPL)" :bullet-points ((:description "Set a toplevel variable to an object:" :examples ((:code (setq obj (make-object 'wing))))) (:description "Then ask it a question (i.e. \"send it a message\"):" :examples ((:code (the-object obj taper) :return-value 1/2))) (:description "Note the rational number (1/2) as a return value."))) (:title "Using self to Avoid the Need for the-object" :bullet-points ((:description "Two ways to set self to a new object:" :examples ((:code (setq self (make-object 'wing))) (:code (make-self 'wing)))) (:description ,(with-htm "Now you can just use " ((:span :class "gdl-operator") "the") " instead of " ((:span :class "gdl-operator") "the-object object...")) :examples ((:code (the taper)) (:return-value 1/2))) (:description ,(with-htm ((:span :class "gdl-object-def") "self") " is set automatically within scope of " ((:span :class "define-object") "self") ".")) (:description ,(with-htm "So there is heavy use of " ((:span :class "gdl-operator") "the") " inside most object definitions:") :examples ((:define-object gdl-user::wing))) (:description ,(with-htm (:small (:i "Example code is " ((:a :href "https://github.com/genworks/gendl/blob/master/documentation/training/g102-tud/examples/source/ch2-examples.lisp" :target "_fresh") "here") ". Press \"Raw\" for raw downloadable form.")))))) (:title "Making and Using Objects in \"tasty\"" :bullet-points ((:description "Visit http://localhost:9000/tasty" :image-url "tasty-wing-entry.png") (:description "This creates an instance of wing and shows you different views of it."))) (:title "Components of Tasty" :bullet-points ((:description ,(with-htm "Tree:" (:ul (:li "expand/condense") (:li "perform selected \"click-mode\" action") (:li "root node is your instance") (:li "select click-mode from Tree menu")))) (:description ,(with-htm "Inspector:" (:ul (:li "View slots of an object") (:li "Drill-down into list and sequence values") (:li "Modify settable slots")))) (:description ,(with-htm "Viewport:" (:ul (:li "Graphical visualization") (:li "Select format from View menu") (:li "x3dom currently needs browser refresh"))) :image-url "tasty-wing.png") )) (:title "\"Breaking\" on an object" :bullet-points ((:description ,(with-htm "You can use the break icon (" ((:img :src (format nil "~abreak-icon.png" (the image-base-url)))) ") to set " ((:span :class "lisp-code") "self") " to the next-clicked object")) (:description "The concept of \"break\" is from Olden Times when browser could not work at the same time as command repl.") (:description ,(with-htm "Click on the " ((:img :src (format nil "~abreak-icon.png" (the image-base-url)))) " and then on the " ((:img :src (format nil "~awing-in-tree.png" (the image-base-url)))) ", then you can work with that wing instance as " ((:span :class "lisp-code") "self") " on the command repl:") :examples ((:code (the taper) :return-value 1/2))))) (:title ,(with-htm ((:span :class "gdl-section-keyword") ":input-slots")) :bullet-points ((:description ,(with-htm "You can specify " ((:span :class "gdl-section-keyword") ":input-slots") " to be able to give values to certain slots at the time of an object's birth.") :image-url "uml-2-8.png" :examples ((:define-object gdl-user::wing-with-input))) (:description ,(with-htm (:small (:i "Example code is " ((:a :href "https://github.com/genworks/gendl/blob/master/documentation/training/g102-tud/examples/source/ch2-examples.lisp" :target "_fresh") "here") ". Press \"Raw\" for raw downloadable form.")))))) (:title ,(with-htm "Providing Values for " ((:span :class "gdl-section-keyword") ":input-slots") " when an Instance is Born") :bullet-points ((:description ,(with-htm ((:span :class :lisp-code) "make-object") " and " ((:span :class :lisp-code) "make-self") " accept " (:i "optional keyword arguments") " corresponding to the input-slots of the object type being created.")) (:description ,(with-htm "What are Keyword Arguments?" (:ul (:li "Keyword symbols are symbols (i.e. Lisp words) preceded by a colon (:)") (:li "Keyword Arguments are keyword-value pairs") (:li "They consist of a keyword symbol (the name) followed by the actual argument value.") (:li "Example: " ((:span :class "lisp-code") ":b 12") " is a keyword-value pair.")))) (:description ,(with-htm "Let's make a " ((:span :class "lisp-code") "wing-with-input") " with a value of " ((:span :class "lisp-code") "12") " for its input-slot " ((:span :class "gdl-message-name") "b")) :examples ((:code (make-self 'wing-with-input :b 12) :return-value ";; self is now set to a wing-with-input object instance.") (:code (the b) :return-value 12) (:code (the S) :return-value 54) (:code (the A) :return-value 8/3))) (:description "Later you will see that input values are passed into Child Objects in the same manner."))) (:title ,(with-htm ((:span :class "gdl-section-keyword") ":input-slots")) :bullet-points ((:description ,(with-htm :br ((:span :class "lisp-code") "(") ((:span :class "gdl-message-name") "a") ((:span :class "gdl-comment") " ;; Required input - no default value") :br "&nbsp;&nbsp;" ((:span :class "lisp-code") "(") ((:span :class "gdl-message-name") "b") ((:span :class "lisp-code") ")") ((:span :class "gdl-comment") " ;; optional - default is nil") :br "&nbsp;&nbsp;" ((:span :class "lisp-code") "(") ((:span :class "gdl-message-name") "c 10") ((:span :class "lisp-code") ")") ((:span :class "gdl-comment") " ;; optional - default is 10") :br "&nbsp;&nbsp;" ((:span :class "lisp-code") "(") ((:span :class "gdl-message-name") "d 20 :settable") ((:span :class "lisp-code") "))") ((:span :class "gdl-comment") " ;; optional - default is 20, can be \"bashed\""))))) (:title "Wing with more Inputs" :bullet-points ((:description "This wing has two settable input-slots" :image-url "uml-2-9c.png" :examples ((:define-object gdl-user::wing-more-inputs))) (:description ,(with-htm (:small "Example code is " ((:a :href "https://github.com/genworks/gendl/blob/master/documentation/training/g102-tud/examples/source/ch2-examples.lisp" :target "_fresh") "here") ". Press \"Raw\" for raw downloadable form."))))) (:title "Exercise 1: make a Fuselage object" :bullet-points ((:description ,(with-htm "Parameters (i.e. Inputs):" (:ul (:li "diameter (d)") (:li "length (l)")))) (:description ,(with-htm "Outputs:" (:ul (:li "volume (V)") (:li "wetted surface (Sw)") (:li "slenderness-ratio (= l / d)")))))) (:title "Exercise 1 Solution" :bullet-points (#+nil (:description "Don't look at this until You Try It:" :image-url "uml-2-10b.png" :examples ((:define-object gdl-user::fuselage))) (:description ,(with-htm (:small "Solutions code will be available later."))))) (:title "Child Objects" :bullet-points ((:description "UML \"Has-a\" relationship" :image-url "uml-2-12.png") (:description "Skeleton Engine Definition:" :examples ((:define-object gdl-user::engine))) (:description "Wing with a single engine as Child Object:" :examples ((:define-object gdl-user::wing-with-engine))) )) (:title "Child Object in a Sequence" :bullet-points ((:description "Specify keyword :size and an expression returning an integer." :image-url "uml-2-12.png" :examples ((:define-object gdl-user::wing-with-engines))))) (:title "Working with Sequences" :bullet-points ((:description ,(with-htm ((:span :class "lisp-code") "list-elements") " converts a sequence into a Lisp list.")) (:description "Try these after \"breaking\" on a wing-with-engines:" :examples ((:code (list-elements (the engines)) :return-value (engine-x24a47d42 engine-x24a47f9a engine-x24a481c2 engine-x24a483ea)) (:code (list-elements (the engines) (the-element Tmax)) :return-value (1000 800 900 1200)))) (:description "Access an element with direct index referencing" :examples ((:code (the (engines 2)) :return-value engine-x24a481c2) (:code (the (engines 2) Tmax) :return-value 900))) (:description ,(with-htm "Using " ((:span :class "lisp-code") "nth") " with " ((:span :class "lisp-code") "list-elements") " also works, but is less efficient") :examples ((:code (nth 2 (list-elements (the engines))) :return-value engine-x24a481c2) (:code (the-object (nth 2 (list-elements (the engines))) Tmax) :return-value 900))))) (:title "Lisp background: <i>Plists</i>" :bullet-points ((:description "Property List, a type of <i>map</i>") (:description "This is a list of pairs") (:description "Maps keyword symbols (i.e. names) to values") (:description ,(with-htm "Use " ((:span :class "lisp-code") "getf") " to access a value for a given keyword:") :examples ((:code (setq list (list :a 1 :b 2 :c 3)) :return-value (:a 1 :b 2 :c 3)) (:code (getf list :b) :return-value 2) (:code (getf list :c) :return-value 3) (:code (getf list :d) :return-value nil))))) (:title "Exercise 2" :bullet-points ((:description "Define an object representing a fuel tank.") (:description ,(with-htm "Parameters (i.e. " ((:span :class :gdl-section-keyword) "input-slots") ") are:" (:ul (:li ((:span :class :gdl-message-name) "h")) (:li ((:span :class :gdl-message-name) "w")) (:li ((:span :class :gdl-message-name) "l"))))) (:description ,(with-htm "Include a method (i.e. " ((:span :class :gdl-section-keyword) "computed-slot") ") to calculate the " ((:span :class :gdl-message-name) "volume") ".")) (:description ,(with-htm "Add a sequence of " ((:span :class :gdl-message-name) "fuel-tanks") " in the wing-with-engines, driven by the following plist:") :examples ((:code (list (list :w 4 :l 3.5 :h 0.3 ) (list :w 2 :l 2.5 :h 0.2 ) (list :w 1.5 :l 2 :h 0.15))))))) (:title "Solution, Part 1" :bullet-points ((:description "First, our fuel tank definition (code will be provided later):" :image-url "uml-sol2.png" ;;:examples #+nil ((:define-object gdl-user::fuel-tank)) ))) (:title "Solution, Part 2" :bullet-points ((:description "Then, our wing definition (code will be provided later):" :image-url "uml-sol2-contd.png" ;;:examples #+nil ((:define-object gdl-user::wing-with-tanks))) (:description "Yes, there is a shorter way to do the inputs for the fuel-tank object (but do it the long way for now)."))) (:title "How it might look in Tasty" :bullet-points ((:description "Something like this:" :image-url "wing-tanks-tasty.png"))) (:title "GDL Functions" :bullet-points ((:description "All the fun of Lisp Functions and GDL Objects, rolled up into one!") (:description "Aircraft assembly with friction force function:" :image-url "uml-2-15.png" :examples ((:define-object gdl-user::aircraft))))) (:title "Calling GDL Functions" :bullet-points ((:description "With make-object on command repl:" :examples ((:code (setq obj (make-object 'aircraft))) (:code (the-object obj (compute-friction-force 50)) :return-value 5903.793955680823) (:code (the-object obj (compute-friction-force 150)) :return-value 53134.145601127406))) (:description "After break/set-self in tasty") (:description "Procedurally from within another function"))) (:title "Exercise 3" :bullet-points ((:description ,(with-htm "Add a function " ((:span :class :gdl-message-name) "lift") " to the aircraft class.")) (:description ,(with-htm "Your function should accept " ((:span :class :lisp-code) "speed") " and " ((:span :class :lisp-code) "C-of-L") " as its arguments, and should yield the value of " ((:span :class :gdl-message-name) "lift") ".")) (:description ,(with-htm "Test the function for the following values of C-of-L:" ((:span :class :lisp-code) "(0.15 0.18 0.20 0.22 0.25)"))) (:description "Compare with your neighbor."))) (:title "Solution" :bullet-points ((:description "Note that this could also mix-in the original aircraft, and avoid the repeated code (code will be provided later)." :image-url "uml-2-17.png" ;;:examples ((:define-object gdl-user::aircraft-with-lift)) ))) (:title "Today's Cumulative UML object Tree" :bullet-points ((:description ,(with-htm ((:span :class :lisp-code) "My-B52") " can mix-in and extend " ((:span :class :lisp-code) "aircraft-with-lift") ".") :image-url "final-uml.png")))))))
25,873
Common Lisp
.lisp
557
37.675045
138
0.590951
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3c871fba449a50c694b1f71248f9b97de484d3c5f2b686ccc37d1a6922af51fb
36,245
[ -1 ]
36,246
publish.lisp
lisp-mirror_gendl/documentation/training/g102-tud/source/publish.lisp
(in-package :training-g102-tud) (publish :path "/training-g102-tud" :function #'(lambda(req ent) (gwl-make-object req ent "training-g102-tud:assembly"))) (print-variables *load-truename*) (defparameter *images-path* (merge-pathnames "documentation/training/g102-tud/images/" glisp:*gendl-source-home*)) (publish-directory :prefix "/g102-tud/images/" :destination (format nil "~a" *images-path*)) (defun push! () (glisp:run-shell-command "rm -r /tmp/sites/") (gwl:crawl "training-g102-tud:assembly") (glisp:run-shell-command "mv /tmp/sites/assembly/ /tmp/sites/training-g102-tud/") (glisp:run-shell-command "rsync -zav /tmp/sites/training-g102-tud/ genworks.com:kitchen/downloads/training-g102-tud/") (glisp:run-shell-command "rm -r /tmp/sites/"))
786
Common Lisp
.lisp
14
52.357143
120
0.724638
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
67ec056acfd6e29ca3816477bd7985222121dd87bbdf362f822a33cc68a49161
36,246
[ -1 ]
36,247
emacs-editing-gendl.lisp
lisp-mirror_gendl/documentation/training/video-outlines/emacs-editing-gendl.lisp
(:video :url "http://youtube..." :outline " 1. Parenthesis balancing 2. Indentation a. line at a time with TAB b. form at a time with C-M-q 3. Stacked parentheses (not dangling) 4. Selecting to copy/cut a. C-<space> marks the beginning of selection b. Any movement of Point adjusts the selection 5. Copying/Cutting a. First you need to make a selection, then: b. C-w cuts c. M-w copies. 6. Yanking (Pasting) a. Move the point to where you want the insertion b. C-y yanks (pastes) c. M-y (immediately following C-y) yanks previous items (circular) 7. Moving forward a. Character at a time with C-f b. Word at a time M-f c. S-expression (sentence) at a time with C-M-f (b instead of f for moving backward). ")
800
Common Lisp
.lisp
24
28.5
69
0.692204
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e2694c105cbc36115e002fb717aab069fe969d07b5e9e27087507cb87a32d520
36,247
[ -1 ]
36,248
package.lisp
lisp-mirror_gendl/documentation/training/slide-show/source/package.lisp
;; ;; Copyright 2002-2011, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (gwl:define-package :slide-show (:export #:slide-show-root-part #:slide-show-node #:slide-show-leaf))
949
Common Lisp
.lisp
21
43.952381
101
0.759179
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
57fcb9fc35e9e93a9bd226f5f701cc657adb05a6d304b961bc0c8ee82dbc45c6
36,248
[ -1 ]
36,249
publish.lisp
lisp-mirror_gendl/documentation/training/slide-show/source/publish.lisp
;; ;; Copyright 2002-2011, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :slide-show) ;; ;; FLAG -- change these to source-code relative pathnames ;; #+nil (publish-directory :prefix "slide-show-images/" :destination (format nil "~a" (translate-logical-pathname "genworks:gwl-apps;slide-show;images;"))) #+nil (publish-directory :prefix "slide-show-style/" :destination (format nil "~a" (translate-logical-pathname "genworks:gwl-apps;slide-show;style;")))
1,249
Common Lisp
.lisp
32
37.65625
100
0.757002
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e605905870b728a43ffdf592ad3ed11cabe8d0f31b989210e14d2cd1a87be4b5
36,249
[ -1 ]
36,250
assembly.lisp
lisp-mirror_gendl/demos/bus/source/assembly.lisp
;; ;; Copyright 2002-2011, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object assembly (node-mixin) :input-slots ( (strings-for-display "School Bus") (wheelbase 300 :settable) (track 96 :settable) (height 80 :settable) (length 0) (width 0) (turn-angle 0 :settable) (number-of-rows 10 :settable) (display-controls (list :vrml-navigation-info (list "speed" 5) :vrml-viewpoints (list (list "position" (translate (the center) :up 500 :right (half (the wheelbase))))))) (show-display-list? t) (use-local-box? nil) (use-standard-saved-slots? t) ) :trickle-down-slots (:show-display-list?) :objects ((body-frame-overhang :type 'body-frame-overhang-rule :chassis-front-overhang (the chassis front-overhang) :body-front-overhang (the body front-overhang)) (chassis :type 'chassis :pass-down (wheelbase track turn-angle) :datum (the center) :height 20) (body :type 'body :pass-down (:wheelbase :track) :frame-width (the chassis frame-width) ;;:frame-overhang (- (the-child front-overhang) ;;(the chassis front-overhang)) :firewall-base (translate (the center) :up (half (the chassis frame-height)) :right (- (the-child cab-width) (the-child body-frame-overhang result)))) (interior :type 'interior :firewall-base (the body :firewall-base) :width (- (the body width) (the body cab-width)) :length (the body length) :height (the body height) :number-of-rows (the number-of-rows))) :hidden-objects ((axis-x :type 'box :length 1 :width 100 :height 1) (axis-y :type 'box :length 100 :width 1 :height 1) (axis-z :type 'box :length 1 :width 1 :height 100))) (define-object body-frame-overhang-rule (gwl-rule-object) :input-slots (chassis-front-overhang body-front-overhang) :computed-slots ((target-value 15) (result (- (the body-front-overhang) (the chassis-front-overhang))) (rule-result (the result)) (rule-result-help "Computed by subtracting the front overhang of the chassis from the front overhang of the body.") (violated? (< (the result) (the target-value))) (rule-description "Amount of overhang of body over axle") (rule-title "Chassis Front Overhang")))
3,860
Common Lisp
.lisp
80
34.7625
113
0.598748
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ce60badeb409e889519c0490d784e0a96a2550511652301c681d21fd23a9596a
36,250
[ -1 ]
36,251
inter-seat-spacing.lisp
lisp-mirror_gendl/demos/bus/source/inter-seat-spacing.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object inter-seat-spacing (gwl-rule-object) :input-slots (max-reclined-angle usable-cabin-width number-of-rows) :computed-slots ((rule-title "Seat Spacing") (rule-description "Distance from front of one seat to front of the next.") (rule-result (number-format (the :result) 2)) (x-extent-typical (the :seat-at-max :x-extent)) (clearance-extent-typical (the :seat-at-max :clearance-extent)) (x-max-typical (the :seat-at-max :x-max)) (result (let ((extra-space (- (the :usable-cabin-width) (* (the :x-extent-typical) (the :number-of-rows)) (the :x-max-typical)))) (+ (the :x-extent-typical) (/ extra-space (the :number-of-rows)))))) :hidden-objects ((seat-at-max :type 'seat :reclined-angle (the :max-reclined-angle))))
1,729
Common Lisp
.lisp
41
38.317073
78
0.70143
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
dd990d6d689778a1d988366de8e7383b1a3e5bfa31f7cc5663bd513b6e0e0605
36,251
[ -1 ]
36,252
package.lisp
lisp-mirror_gendl/demos/bus/source/package.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (gwl:define-package :genworks.demos.bus (:documentation #.(glisp:system-description :bus)) (:nicknames :bus) (:export #:assembly #:fleet))
1,063
Common Lisp
.lisp
24
41.291667
71
0.735151
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8418b8e50f1f4c96837bf28cdaa2693bc26de5456c7d4265401a6b473713f6af
36,252
[ -1 ]
36,253
runtime.lisp
lisp-mirror_gendl/demos/bus/source/runtime.lisp
(in-package :bus) (define-object runtime-maker (build-utils:runtime-maker) :computed-slots ((source-directory *source-directory*))) (defun make-runtime () (let ((self (make-object 'runtime-maker))) (the make)))
240
Common Lisp
.lisp
7
29.142857
57
0.692308
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cc7c6c9c5fcd2de8506d7e924e21c3abbe68143d0bdddb871ce66cdc7f0fbe26
36,253
[ -1 ]
36,254
fleet.lisp
lisp-mirror_gendl/demos/bus/source/fleet.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :bus) #+nil (define-object fleet (base-object) :input-slots ((csv-file (merge-pathnames "fleet.csv" *data-directory*))) :computed-slots ((csv-data (fare-csv:read-csv-file (the csv-file))) (active-data-rows (remove-if #'(lambda(row) (the-object row in-maintenance?)) (list-elements (the data-rows))))) :hidden-objects ((data-rows :type 'bus-data-row :sequence (:size (length (the csv-data))) :data-list (nth (the-child index) (the csv-data)))) :objects ((busses :type 'assembly :sequence (:size (length (the active-data-rows))) :center (translate (the center) :rear (* (the-child index) 150)) ;; ;; Data-row is a "psuedo-input" -- it is not actually an input-slot for assembly, but used only ;; here for convenience so that the wheelbase and number-of-rows can refer to (the-child data-row ...) ;; :data-row (nth (the-child index) (the active-data-rows)) :wheelbase (the-child data-row wheelbase) :number-of-rows (the-child data-row number-of-seat-rows)))) #+nil (define-object bus-data-row () :input-slots (data-list) :computed-slots ((wheelbase (first (the data-list))) (number-of-seat-rows (second (the data-list))) (in-maintenance? (string-equal (third (the data-list)) "yes"))))
2,249
Common Lisp
.lisp
50
39.96
107
0.688723
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e16be98d2222ce630df04f3fad594a5428be834ce70cf004d7adf8fbe5610b99
36,254
[ -1 ]
36,255
body.lisp
lisp-mirror_gendl/demos/bus/source/body.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object body (application-mixin) :input-slots (wheelbase track firewall-base frame-width) :computed-slots ((ui-display-list-objects (the children)) (width (+ (the :wheelbase) (the :front-overhang) (the :rear-overhang))) (rear-overhang 84 :settable) (front-overhang 35 :settable) (cab-width 54 :settable) (height 72 :settable) (length 96 :settable) (use-local-box? nil)) :objects ( (extruded-box :type 'global-filleted-polygon-projection :radius-list (list 10 10 10 10 10 10 1 1) :projection-depth (the :reference-box :width) :projection-vector (the (:face-normal-vector :right)) :vertex-list (list (the :reference-box (:vertex :left :rear :bottom)) (translate (the :reference-box (:vertex :left :rear :top)) :down 12) (translate (the :reference-box (:vertex :left :rear :top)) :front 20 :down 4) (translate (the :reference-box (:vertex :left :rear :top)) :front 45) (translate (the :reference-box (:vertex :left :front :top)) :rear 45) (translate (the :reference-box (:vertex :left :front :top)) :rear 20 :down 4) (translate (the :reference-box (:vertex :left :front :top)) :down 12) (the :reference-box (:vertex :left :front :bottom))) :display-controls (list :color :gold-bright :ambient-intensity 0.0 :shininess 0.7 :specular-color :orange :transparency 0.4)) (extruded-cab :type 'global-filleted-polygon-projection :radius-list (list 7 7 1 1) :projection-depth (the :cab-box :height) :projection-vector (the (:face-normal-vector :bottom)) :vertex-list (list (the :cab-box (:vertex :top :rear :right)) (translate (the :cab-box (:vertex :top :rear :left)) :front 16) (translate (the :cab-box (:vertex :top :front :left)) :rear 16) (the :cab-box (:vertex :top :front :right))) :display-controls (list :color :gold-bright :ambient-intensity 0.0 :shininess 0.7 :specular-color :orange))) :hidden-objects ((reference-box :type 'box :center (translate (the :firewall-base) :up (half (the :height)) :right (* (half (the-child :width)) 1.001)) :width (- (the :width) (the :cab-width)) :length (* 1.01 (the length)) :display-controls (list :color :gold-bright)) (cab-box :type 'box :center (translate (the :firewall-base) :up (half (the-child :height)) :left (half (the-child :width))) :height (half (the :height)) :width (the :cab-width) :display-controls (list :color :gold-bright))))
3,586
Common Lisp
.lisp
83
37.240964
130
0.654974
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
569d23d418b734868e50cbadf769a7f5bb12454158cb67d171f2ed95937e9da4
36,255
[ -1 ]
36,256
html-writer-rule-ackermann.lisp
lisp-mirror_gendl/demos/bus/source/html-writer-rule-ackermann.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-lens (html-format rule-ackermann) nil :output-functions ((bottom-user-area () (the (:write-geometry :include-view-controls? nil)))))
1,083
Common Lisp
.lisp
27
37.037037
71
0.732314
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f27762966c825d29fe0acf1cd7fecdf975c9f396ae19c9e61a4b7174ecc35f78
36,256
[ -1 ]
36,257
seating-side.lisp
lisp-mirror_gendl/demos/bus/source/seating-side.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object seating-side (base-object) :input-slots (reclined-angle fare-class side body-reference-point number-of-rows x-vector x-max-typical inter-seat-spacing ) :computed-slots ((inboard-direction (ecase (the side) (:left :rear) (:right :front))) (use-local-box? nil) ) :objects ((seats :type 'seat :sequence (:size (the number-of-rows)) :pass-down (:reclined-angle :max-reclined-angle :x-vector) :pseudo-inputs (transformation-matrix) :transformation-matrix (alignment :rear (the-child y-vector) :right (the-child x-vector) :top (the-child z-vector)) :orientation (the-child transformation-matrix) :center (translate (the body-reference-point) :up (+ (the-child (legs 0) height) (the-child base height)) :left (+ (the x-max-typical) (* (the-child index) (the inter-seat-spacing))) (the inboard-direction) (half (the-child base-length))))))
1,948
Common Lisp
.lisp
57
29.403509
71
0.685363
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
fefd08f9a3451eba33681335b1ff538bfcaff2eb22ba2726e08761c70885c87a
36,257
[ -1 ]
36,258
html-writer-interior.lisp
lisp-mirror_gendl/demos/bus/source/html-writer-interior.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-lens (html-format interior) nil :output-functions ((model-inputs () (html-form (number-of-rows reclined-angle max-reclined-angle minimum-inter-seat-clearance) :prompts ("Rows" "Displayed Angle" "Max Angle" "Req'd Legroom")))))
1,196
Common Lisp
.lisp
29
37.655172
71
0.721792
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a62c4b95059fa6654b60fd0ff523fb43b83bbf15d990abdf8cdf9fadfea27c65
36,258
[ -1 ]
36,259
html-writer-chassis.lisp
lisp-mirror_gendl/demos/bus/source/html-writer-chassis.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-lens (html-format chassis) nil :output-functions ((model-inputs () (html (:p (:table (:tr ((:td :bgcolor :yellow) "Front Overhang") (:td ((:input :type :text :size 5 :name :front-overhang :value (the :front-overhang))))) (:tr ((:td :bgcolor :yellow) "Rear Overhang") (:td ((:input :type :text :size 5 :name :rear-overhang :value (the :rear-overhang))))) (:tr ((:td :bgcolor :yellow) "Turn Type") (:td (the (:select-choices :name :turn-type :keys (list :left :right))))) (:tr ((:td :bgcolor :yellow) "Turn Angle") (:td ((:input :type :text :size 5 :name :turn-angle :value (the :turn-angle))))) (:tr ((:td :bgcolor :yellow) "Toe-In Angle") (:td ((:input :type :text :size 5 :name :toe-in-angle :value (the :toe-in-angle))))) (:tr ((:td :bgcolor :yellow) "Camber Angle") (:td ((:input :type :text :size 5 :name :camber-angle :value (the :camber-angle))))) (:tr ((:td :bgcolor :yellow) "Caster Angle") (:td ((:input :type :text :size 5 :name :caster-angle :value (the :caster-angle))))) (:tr ((:td :bgcolor :yellow) "KPI") (:td ((:input :type :text :size 5 :name :kingpin-inclination-angle :value (the :kingpin-inclination-angle))))) (:tr ((:td :bgcolor :yellow) "Tie Rod" :br "Arm Length") (:td (the (:select-choices :name :tie-rod-arm-length :keys (list :short :medium :long) :values (list "Short" "Medium" "Long"))))) (:tr ((:td :bgcolor :yellow) "Tie Rod" :br "Arm Setting") (:td (the (:select-choices :name :tie-rod-arm-setting :keys (list :narrow :medium :wide) :values (list "Narrow" "Medium" "Wide"))))))) (:p ((:input :type :submit :name :subbmit :value " OK ")))))))
2,748
Common Lisp
.lisp
69
34.768116
73
0.623644
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a2753d550020fd4edc9b1833dd95cdf402efddd39adf5d2c0926b1b286a1257e
36,259
[ -1 ]
36,260
html-writer-assembly.lisp
lisp-mirror_gendl/demos/bus/source/html-writer-assembly.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-lens (html-format assembly) () :output-functions ((model-inputs nil (html (:p (:table (:tr ((:td :bgcolor :yellow) "Wheelbase") (:td ((:input :type :text :size 5 :name :wheelbase :value (the :wheelbase))))) (:tr ((:td :bgcolor :yellow) "Track") (:td ((:input :type :text :size 5 :name :track :value (the :track))))) (:tr ((:td :bgcolor :yellow) "Height") (:td ((:input :type :text :size 5 :name :height :value (the :height))))))) (:p ((:input :type :submit :name :ok :value " OK ")))))))
1,534
Common Lisp
.lisp
40
33.55
71
0.650067
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
19d101caa7f77c31c4bcd1939ea4822cc7daed2b7a0b273ed957c63b243cd28f
36,260
[ -1 ]
36,261
publish.lisp
lisp-mirror_gendl/demos/bus/source/publish.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :bus) (publish :path "/demos/bus" :function #'(lambda(req ent) (gwl-make-part req ent "bus:assembly"))) (publish :path "/demos/busi" :function #'(lambda(req ent) (gwl-make-part req ent "bus:assembly" :skin 'gwl:infinite)))
1,149
Common Lisp
.lisp
27
39.296296
71
0.718133
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
608e153b5c738e03b9a4925990adef0c9a30be552eeee29e24932f16b2b4a764
36,261
[ -1 ]
36,262
seat.lisp
lisp-mirror_gendl/demos/bus/source/seat.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object seat (base-object) :input-slots (fare-class reclined-angle max-reclined-angle (x-vector (make-vector 1 0 0)) (y-vector (make-vector 0 1 0)) (z-vector (make-vector 0 0 1)) (base-width 18) (base-height 3.5) (base-length 36) (back-width 25) (back-height (* (the :base-height) 1.33)) (back-length (the :base-length)) (leg-width 3.5) (leg-height 15) (leg-length (* (the :base-length) 0.69)) (leg-offset 4) (use-local-box? nil) ) :computed-slots ((self-orientation (alignment :rear (the :y-vector) :right (the :x-vector) :top (the :z-vector))) (clearance-max (- (get-x (the :back (:face-center :bottom))) (get-x (the :center)))) (x-max (- (get-x (the :back (:edge-center :bottom :right))) (get-x (the :center)))) (x-min (- (get-x (the :base (:edge-center :top :left))) (get-x (the :center)))) (clearance-extent (- (the :clearance-max) (the :x-min))) (x-extent (- (the :x-max) (the :x-min)))) :objects ((legs :type 'box :sequence (:size 2) :length (the :leg-length) :width (the :leg-width) :height (the :leg-height) :center (translate (the :center) :down (+ (half (the-child :height)) (the :base-height)) :left (ecase (the-child :index) (0 (- (the :base :width) (the :leg-offset))) (1 (the :leg-offset))))) (base :type 'box :length (the :base-length) :width (the :base-width) :height (the :base-height) :center (translate (the :center) :left (half (the-child :width)) :down (half (the-child :height)))) (back :type 'box :length (the :back-length) :width (the :back-width) :height (the :back-height) :center (let ((nominal-center (translate (the :center) :up (half (the-child :width))))) (rotate-point-d nominal-center (the :center) (the :y-vector) :angle (the :reclined-angle))) :pseudo-inputs (transformation-matrix) :transformation-matrix (alignment :right (rotate-vector-d (the :z-vector) (the :reclined-angle) (the :y-vector)) :top (rotate-vector-d (reverse-vector (the :x-vector)) (the :reclined-angle) (the :y-vector))) :orientation (the-child :transformation-matrix))))
3,244
Common Lisp
.lisp
87
32
83
0.633036
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cc33c6dcb5907a05278b0619edbb2d60e83a1a147db110ada691f1ec652a959d
36,262
[ -1 ]
36,263
chassis.lisp
lisp-mirror_gendl/demos/bus/source/chassis.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object chassis (application-mixin) :input-slots (wheelbase track datum height (turn-angle 0 :settable) ) :computed-slots ((respondent self) (ui-display-list-objects (remove-if #'(lambda (item) (typep item 'base-rule-object)) (the :children))) (frame-width (the :frame :width)) (frame-height (the :frame :height)) (left-rotation (- (ecase (the :turn-type) (:left (the :turn-angle)) (:right (if (the :left-hit-point) (angle-between-vectors-d (the (:knuckles-straight 0) :tie-rod-arm-vector) (subtract-vectors (the :left-hit-point) (the (:knuckles-straight 0) :tie-rod-arm-axis-point)) (the (:knuckles-straight 0) :top-vector) t) 0))) (the :toe-in-angle))) (right-rotation (+ (ecase (the :turn-type) (:right (the :turn-angle)) (:left (if (the :right-hit-point) (angle-between-vectors-d (the (:knuckles-straight 1) :tie-rod-arm-vector) (subtract-vectors (the :right-hit-point) (the (:knuckles-straight 1) :tie-rod-arm-axis-point)) (the (:knuckles-straight 1) :top-vector) t) 0))) (the :toe-in-angle))) (tie-rod-length (3d-distance (the (:knuckles-straight 0) :tie-rod-arm-end) (the (:knuckles-straight 1) :tie-rod-arm-end))) (left-hit-point (let ((circle (the (:knuckles-straight 0) :tie-rod-arm-circle)) (sphere (the (:knuckles 1) :tie-rod-sphere))) (inter-circle-sphere (getf circle :center) (getf circle :radius) (getf circle :axis-vector) (getf sphere :center) (getf sphere :radius) nil))) (right-hit-point (let ((circle (the (:knuckles-straight 1) :tie-rod-arm-circle)) (sphere (the (:knuckles 0) :tie-rod-sphere))) (inter-circle-sphere (getf circle :center) (getf circle :radius) (getf circle :axis-vector) (getf sphere :center) (getf sphere :radius) t))) (front-overhang 25 :settable) (rear-overhang 72 :settable) (frame-rail-height 6 :settable) (frame-rail-thickness 2.5 :settable) (turn-type :left :settable) (toe-in-angle 0.5 :settable) (camber-angle 1.0 :settable) (caster-angle -1.0 :settable) (kingpin-inclination-angle 7 :settable) (tie-rod-arm-length :medium :settable) (tie-rod-arm-setting :medium :settable) (ackermann-data (let ((chassis (make-object 'chassis :wheelbase (the wheelbase) :track (the track) :datum (the datum) :height (the height))) (left-angles (list-of-numbers 1 35)) right-angles) (the-object chassis (set-slots! (list :front-overhang (the front-overhang) :rear-overhang (the rear-overhang) :frame-rail-height (the frame-rail-height) :frame-rail-thickness (the frame-rail-thickness) :toe-in-angle 0 :camber-angle (the camber-angle) :caster-angle (the caster-angle) :kingpin-inclination-angle (the kingpin-inclination-angle) :tie-rod-arm-length (the tie-rod-arm-length) :tie-rod-arm-setting (the tie-rod-arm-setting) :turn-type :left))) (setq right-angles (let (result ideal-result) (dolist (left-angle left-angles (list (nreverse result) (nreverse ideal-result))) (the-object chassis (set-slot! :turn-angle left-angle)) (push (the-object chassis right-rotation) result) (let ((rear-axle-intersect (inter-line-plane (the (axles 1) center) (the (face-normal-vector :rear)) (the-object chassis (knuckles 0) center) (the-object chassis (knuckles 0) (face-normal-vector :right))))) (push (angle-between-vectors-d (the (face-normal-vector :rear)) (subtract-vectors (the (knuckles 1) center) rear-axle-intersect)) ideal-result))))) (list :left (cons 0 left-angles) :right (cons 0 (first right-angles)) :ideal-right (cons 0 (second right-angles))))) ) :objects ((knuckles :type 'knuckle :pseudo-inputs (front-vector left-vector top-vector transformation-matrix) :sequence (:size 2) :side (ecase (the-child :index) (0 :left) (1 :right)) :top-vector (getf (the (:axles 0) :kingpin-vectors) (the-child :side)) :front-vector (cross-vectors (the-child :top-vector) (the (:face-normal-vector (the-child :side)))) :left-vector (cross-vectors (the-child :top-vector) (ecase (the-child :side) (:left (reverse-vector (the-child :front-vector))) (:right (the-child :front-vector)))) :pass-down (:tie-rod-length :tie-rod-arm-length :tie-rod-arm-setting) :spindle-downward-pitch (+ (the :kingpin-inclination-angle) (the :camber-angle)) :center (the (:axles 0) (:kingpins (the-child :index)) :center) :transformation-matrix (alignment :top (the-child :top-vector) :front (rotate-vector-d (the-child :front-vector) (ecase (the-child :side) (:left (the :left-rotation)) (:right (the :right-rotation))) (the-child :top-vector)) :left (rotate-vector-d (the-child :left-vector) (ecase (the-child :side) (:left (the :left-rotation)) (:right (the :right-rotation))) (the-child :top-vector))) :orientation (the-child :transformation-matrix)) (tie-rod :type 'c-cylinder :radius 1.5 :start (the (:knuckles 0) :tie-rod-arm-end) :end (the (:knuckles 1) :tie-rod-arm-end)) (frame :type 'frame :width (+ (the :wheelbase) (the :front-overhang) (the :rear-overhang)) :length (* 4/9 (the :track)) :height (the :frame-rail-height) :thickness (the :frame-rail-thickness) :center (translate (the :datum) :right (half (the-child :width)))) (axles :type (:sequence '(axle rear-axle)) :sequence (:size 2) :center (translate (the :datum) :down (+ (half (the :frame :height)) (half (the-child :height))) :right (ecase (the-child :index) (0 (the :front-overhang)) (1 (+ (the :front-overhang) (the :wheelbase))))) :transformation-matrix (alignment :left (rotate-vector-d (the (:face-normal-vector :left)) (the :caster-angle) (the (:face-normal-vector :front)))) :orientation (the-child :transformation-matrix) :height 10 :length (- (the :track) (ecase (the-child :index) (0 (twice (the (:wheels-front 0) :length))) (1 (twice (the (:wheels-rear 0) :length))))) :pass-down (:kingpin-inclination-angle) :width 10 :display-controls (list :color :black :line-thickness 2)) (wheels-front :type 'wheel :sequence (:size 2) :pseudo-inputs (transformation-matrix) :center (the (:knuckles (the-child :index)) :spindle-center) :transformation-matrix (alignment :front (the (:knuckles (the-child :index)) :spindle-vector)) :orientation (the-child :transformation-matrix) :length 9 :radius 19 :inner-radius 7 :display-controls (list :color "#333333" :shininess 0.6 :specular-color "#999999" ;; ;; FLAG put back in when we have drag-and-drop in Raphael again - ;; drag-and-drop is commented out in modern-site now. ;; ;;:drag-controls :drag-and-drop ) ) (wheels-rear :type 'wheel :sequence (:size 2) :center (translate (getf (the (:axles 1) :wheel-centers) (ecase (the-child :index) (0 :left) (1 :right))) (ecase (the-child :index) (0 :front) (1 :rear)) (half (the-child :length))) :pseudo-inputs (transformation-matrix) :transformation-matrix (alignment :front (the (:face-normal-vector (ecase (the-child :index) (0 :front) (1 :rear))))) :orientation (the-child :transformation-matrix) :display-controls (list :color "#333333" :shininess 0.6 :specular-color "#999999") :length 15 :radius 19 :inner-radius 7) (rule-ackermann :type 'rule-ackermann :ackermann-data (list :left (getf (the ackermann-data) :left) :right (getf (the ackermann-data) :right)) :ackermann-data-ideal (list :left (getf (the ackermann-data) :left) :right (getf (the ackermann-data) :ideal-right))) ) :hidden-objects ( (knuckles-straight :type 'knuckle :sequence (:size 2) :center (the (:axles 0) (:kingpins (the-child :index)) :center) :side (ecase (the-child :index) (0 :left) (1 :right)) :top-vector (getf (the (:axles 0) :kingpin-vectors) (the-child :side)) :front-vector (cross-vectors (the-child :top-vector) (the (:face-normal-vector (the-child :side)))) :left-vector (cross-vectors (the-child :top-vector) (ecase (the-child :side) (:left (reverse-vector (the-child :front-vector))) (:right (the-child :front-vector)))) :spindle-downward-pitch (+ (the :kingpin-inclination-angle) (the :camber-angle)) :pass-down (:tie-rod-arm-length :tie-rod-arm-setting) :pseudo-inputs (front-vector left-vector top-vector transformation-matrix) :transformation-matrix (alignment :top (the-child :top-vector) :front (rotate-vector-d (the-child :front-vector) (the :toe-in-angle) (ecase (the-child :side) (:left (reverse-vector (the-child :top-vector))) (:right (the-child :top-vector)))) :left (rotate-vector-d (the-child :left-vector) (the :toe-in-angle) (ecase (the-child :side) (:left (reverse-vector (the-child :top-vector))) (:right (the-child :top-vector))))) :orientation (the-child :transformation-matrix))))
11,028
Common Lisp
.lisp
281
31.540925
86
0.613285
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
421ae5dabe1829238239bbe3fd3e5f171708d0cd487c887e65b8d8e06456c031
36,263
[ -1 ]
36,264
seating-section.lisp
lisp-mirror_gendl/demos/bus/source/seating-section.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object seating-section (base-object) :input-slots (fare-class usable-cabin-width body-reference-points max-reclined-angle number-of-rows minimum-inter-seat-clearance (use-local-box? nil) ) :objects ((inter-seat-spacing-computation :type 'inter-seat-spacing :length 0 :width 0 :height 0 :pass-down (:max-reclined-angle :usable-cabin-width :number-of-rows)) (inter-seat-clearance-check :type 'inter-seat-clearance-check :inter-seat-spacing (the inter-seat-spacing-computation result) :clearance-extent-typical (the inter-seat-spacing-computation clearance-extent-typical) :length 0 :width 0 :height 0 :value (the minimum-inter-seat-clearance)) (sides :type 'seating-side :fare-class (the fare-class) :sequence (:size 2) :side (ecase (the-child index) (0 :left) (1 :right)) :display-controls (list :color :green) :body-reference-point (getf (the body-reference-points) (the-child side)) :pass-down (:number-of-rows :reclined-angle) :inter-seat-spacing (the inter-seat-spacing-computation result) :x-max-typical (the inter-seat-spacing-computation x-max-typical) :x-vector (the (face-normal-vector :right)))))
2,206
Common Lisp
.lisp
57
34.087719
71
0.712606
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4334a78a582e2e942a895cbb8234e9914d590b7e5cc86a14a19b6b4c3814c949
36,264
[ -1 ]
36,265
frame-rail.lisp
lisp-mirror_gendl/demos/bus/source/frame-rail.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object frame-rail (box) :input-slots ((display-controls (list :color :green-spring))))
1,019
Common Lisp
.lisp
24
39.875
71
0.740142
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
955b407d1320664dd4b028aa2a353e60ab627d9a99f23c7cdc731b95c3f927ee
36,265
[ -1 ]
36,266
interior.lisp
lisp-mirror_gendl/demos/bus/source/interior.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object interior (application-mixin) :input-slots (firewall-base length width height (number-of-rows 10 :settable)) :computed-slots ((ui-display-list-objects (list (the :sections))) (reclined-angle 20 :settable) (max-reclined-angle 30 :settable) (minimum-inter-seat-clearance 7 :settable) (use-local-box? nil)) :objects ((sections :type 'seating-section :body-reference-points (list :left (translate (the :firewall-base) :front (half (the :length)) :right (the :width)) :right (translate (the :firewall-base) :rear (half (the :length)) :right (the :width))) :usable-cabin-width (the :width) :pass-down (number-of-rows reclined-angle max-reclined-angle minimum-inter-seat-clearance))))
1,770
Common Lisp
.lisp
48
31.875
71
0.693168
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3020ede3319214faccc4cb7de8ffcbb4a372db30c248c8ea72bf9f0c8ac664b3
36,266
[ -1 ]
36,267
axle.lisp
lisp-mirror_gendl/demos/bus/source/axle.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object axle (base-object) :input-slots (kingpin-inclination-angle) :computed-slots ((kingpin-vectors (list :left (the (:kingpins 0) (:face-normal-vector :front)) :right (the (:kingpins 1) (:face-normal-vector :front))))) :objects ((kingpins :type 'cylinder :sequence (:size 2) :radius 1.5 :length (the :height) :center (the (:face-center (ecase (the-child :index) (0 :front) (1 :rear)))) :pseudo-inputs (transformation-matrix) :transformation-matrix (alignment :front (rotate-vector-d (the (:face-normal-vector :top)) (funcall (ecase (the-child :index) (0 #'identity) (1 #'-)) (the :kingpin-inclination-angle)) (the (:face-normal-vector :left)))) :orientation (the-child :transformation-matrix) :display-controls (list :color :red)) (extrusion :type 'global-filleted-polygon-projection :radius-list (list 5 5 5 5 1 1 5 5 5 5 1 1) :projection-depth (the :width) :projection-vector (the (:face-normal-vector :right)) :display-controls (list :color :blue-steel :shininess 7 ) :vertex-list (let* ((d1 9) (d2 8) (d3 5) (d4 7) (top-edge (let* ((a (the (:vertex :front :top :left))) (b (translate a :rear d1)) (c (translate b :down d2 :rear d3)) (d (translate c :rear (- (the :length) (twice (+ d1 d3))))) (e (translate d :up d2 :rear d3)) (f (translate e :rear d1))) (list a b c d e f))) (bottom-edge (mapcar #'(lambda (point) (translate point :down d4)) top-edge))) (append top-edge (nreverse bottom-edge))))))
2,742
Common Lisp
.lisp
75
29.666667
83
0.615414
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
814ad1288cf5bcf26ffa10eb4383ae9dbe6ede792478ad83f476cccd18542919
36,267
[ -1 ]
36,268
rear-axle.lisp
lisp-mirror_gendl/demos/bus/source/rear-axle.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object rear-axle (base-object) :computed-slots ((wheel-centers (list :left (translate (the :center) :front (half (the :length))) :right (translate (the :center) :rear (half (the :length)))))) :objects ((center-sphere :type 'sphere :radius 9) (cylinder :type 'c-cylinder :start (getf (the :wheel-centers) :left) :end (getf (the :wheel-centers) :right) :radius 2.5)))
1,348
Common Lisp
.lisp
34
36.058824
71
0.705972
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8f47526d7f01bb131128f823a7a15f2ffdd57c9f7ccf05790fdb81e0cf42e5c9
36,268
[ -1 ]
36,269
frame.lisp
lisp-mirror_gendl/demos/bus/source/frame.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object frame (base-object) :input-slots (thickness) :objects ((rails :type 'frame-rail :sequence (:size 2) :center (translate (the :center) (ecase (the-child :index) (0 :front) (1 :rear)) (- (half (the :length)) (half (the :thickness)))) :length (the :thickness))))
1,236
Common Lisp
.lisp
31
36.419355
71
0.707602
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
19f837fa7dbc5843e955597b1d903ba6ec7d43028f7c53450910f2c743af9a2b
36,269
[ -1 ]
36,270
knuckle.lisp
lisp-mirror_gendl/demos/bus/source/knuckle.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object knuckle (base-object) :input-slots (side tie-rod-length spindle-downward-pitch tie-rod-arm-length tie-rod-arm-setting (spindle-base-radius 2) (spindle-end-radius 1) (spindle-length 12) (tie-rod-arm-start-offset 3) (tie-rod-arm-end-local (make-point (ecase (the :tie-rod-arm-length) (:short 7) (:medium 10) (:long 13)) (ecase (the :tie-rod-arm-setting) (:narrow 5) (:medium 3) (:wide 0)) 3)) (tie-rod-arm-radius 1.5) (tie-rod-arm-end (the :tie-rod-arm :end))) :computed-slots ((display-controls (list :color :green-forest)) (spindle-vector (the :spindle :direction-vector)) (spindle-center (the :spindle :center)) (tie-rod-arm-vector (the :tie-rod-arm :direction-vector)) (tie-rod-arm-axis-point (inter-line-plane (the :center) (the (:face-normal-vector :top)) (the :tie-rod-arm-end) (the (:face-normal-vector :top)))) (tie-rod-arm-circle (list :center (the :tie-rod-arm-axis-point) :radius (3d-distance (the :tie-rod-arm-axis-point) (the :tie-rod-arm-end)) :axis-vector (the (:face-normal-vector :top)))) (tie-rod-sphere (list :center (the :tie-rod-arm-end) :radius (the :tie-rod-length)))) :objects ((tie-rod-ball :type 'sphere :center (the :tie-rod-arm-end) :radius 2) (tie-rod-arm :type 'c-cylinder :start (translate (the :center) :up (the :tie-rod-arm-start-offset)) :end (translate (the :center) :right (get-x (the :tie-rod-arm-end-local)) :rear (get-y (the :tie-rod-arm-end-local)) :up (get-z (the :tie-rod-arm-end-local))) :radius (the :tie-rod-arm-radius)) (spindle :type 'c-cylinder :start (the :center) :end (translate-along-vector (the :center) (rotate-vector-d (the (:face-normal-vector :front)) (the :spindle-downward-pitch) (ecase (the :side) (:left (the (:face-normal-vector :right))) (:right (the (:face-normal-vector :left))))) (the :spindle-length)) :radius (the :spindle-end-radius))))
3,063
Common Lisp
.lisp
80
32.825
75
0.649176
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5dc00302dcdabd83dfde33c8cbccd7dae8d650bf6231594165c3b3959252ca04
36,270
[ -1 ]
36,271
html-writer-body.lisp
lisp-mirror_gendl/demos/bus/source/html-writer-body.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-lens (html-format body) nil :output-functions ((model-inputs nil (html (:p (:table (:tr ((:td :bgcolor :yellow) "Front Overhang") (:td ((:input :type :text :name :front-overhang :value (the :front-overhang))))) (:tr ((:td :bgcolor :yellow) "Rear Overhang") (:td ((:input :type :text :name :rear-overhang :value (the :rear-overhang))))) (:tr ((:td :bgcolor :yellow) "EC Length") (:td ((:input :type :text :name :cab-width :value (the :cab-width))))) (:tr ((:td :bgcolor :yellow) "Headroom") (:td ((:input :type :text :name :height :value (the :height))))) (:tr ((:td :bgcolor :yellow) "Width Exterior") (:td ((:input :type :text :name :length :value (the :length))))))) (:p ((:input :type :submit :name :subbmit :value " OK ")))))))
1,757
Common Lisp
.lisp
42
37.714286
74
0.65945
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
16bd3d0b6de1ae1a9fbb832ee5d9379d5e857689629c025dacc6fdf8ce1fa50b
36,271
[ -1 ]
36,272
wheel.lisp
lisp-mirror_gendl/demos/bus/source/wheel.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object wheel (cylinder))
949
Common Lisp
.lisp
22
40.772727
71
0.745395
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
bd0958710191c4f171ffaaa7d6d34bc47860d39c625cf16b052c60db2225ca73
36,272
[ -1 ]
36,273
inter-seat-clearance-check.lisp
lisp-mirror_gendl/demos/bus/source/inter-seat-clearance-check.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object inter-seat-clearance-check (gwl-rule-object) :input-slots (inter-seat-spacing clearance-extent-typical value) :computed-slots ((rule-title "Legroom") (rule-description "Distance from front of one seat to back of the seat fore of it.") (rule-result (number-format (the result) 2)) (violated? (< (the result) (the value))) (result (- (the inter-seat-spacing) (the clearance-extent-typical)))))
1,372
Common Lisp
.lisp
33
38.181818
88
0.724267
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f8aa534a012d598f498f3b2c2d8e6fee70c80fc2dc8ade7d6f2e40b56a685075
36,273
[ -1 ]
36,274
parameters.lisp
lisp-mirror_gendl/demos/bus/source/parameters.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :bus) (defparameter *source-directory* (merge-pathnames "../../source/" (make-pathname :name nil :type nil :defaults *load-truename*))) (defparameter *data-directory* (make-pathname :directory (append (butlast (butlast (pathname-directory *load-truename*))) (list "data")) :device (pathname-device *load-truename*)))
1,239
Common Lisp
.lisp
25
46.28
130
0.728027
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7d188cf098c6e15bdda32b6ba6dec501059227f24ce60428f600d90bc1741a19
36,274
[ -1 ]
36,275
rule-ackermann.lisp
lisp-mirror_gendl/demos/bus/source/rule-ackermann.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :genworks.demos.bus) (define-object rule-ackermann (gwl-rule-object) :input-slots (ackermann-data-ideal ackermann-data) :computed-slots ((rule-title "Ackermann") (rule-description "Each right turn angle plotted against the corresponding left turn angle should follow a certain relationship to aid in vehicle handling and avoid tire scrub. In the diagram below, the red curve indicates actual Left wheel turn-angles plotted against the corresonding Right wheel turn angle, and the green curve indicates the Ideal according to Ackermann's rule.") (violated? nil)) :hidden-objects ((graph :type 'graph :x-values (list (getf (the ackermann-data-ideal) :left) (getf (the ackermann-data) :left)) :y-values (list (getf (the ackermann-data-ideal) :right) (getf (the :ackermann-data) :right)) :colors (list :green :red))) :hidden-objects ((view-object :type 'web-drawing :object-roots (list (the :graph)) :page-width 500 :page-length 500)))
1,918
Common Lisp
.lisp
45
38.933333
81
0.732615
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
87d07b82dc2c64e016c507d4848e954e82b5c433e7089f7e2ed81ae3b8db431d
36,275
[ -1 ]
36,276
accounts.lisp
lisp-mirror_gendl/demos/ledger/data/accounts.lisp
("Index" "Name" "Description" "Account Number" "Account Type" "Account Class" "Beginning Balance") (0 "DFCU" "Dearborn Federal Credit Union" "999-6969-999" "Checking" "Asset/Liability" 25000) (1 "Waterhouse" "Waterhouse Taxable" "555-7979-555" "Savings" "Asset/Liability" 12500) (2 "Salary" "Genworks Monthly Salary" "xxx-xxxx-xxx" "Salary" "Income/Expense" 0) (3 "Rent" "Monthly Housing Rent" "N/A" "Rent" "Income/Expense" 0) (4 "Utilities" "Monthly Home Utilities" "N/A" "Utilities" "Income/Expense" 0) (5 "Dining" "Dining out at restaurants" "N/A" "expense" "Income/Expense" 0) (6 "Sports equipment" "Sporting goods and supplies" "N/A" "expense" "Income/Expense" 0) (7 "Wallet" "Cash contents of wallet (don't tell anyone)" "N/A" "Cash" "Asset/Liability" 75) (8 "slush2" "slush2" "333" "slush3" "Asset/Liability" 100) (9 "slush5" "slush5" "87777" "slush" "Asset/Liability" 1000)
904
Common Lisp
.lisp
11
79.181818
100
0.692825
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
fcf03029d50072256bbed5030637780a209da8bb814fefbbfe8fe74cebfa087b
36,276
[ -1 ]
36,277
transactions.lisp
lisp-mirror_gendl/demos/ledger/data/transactions.lisp
("Index" "From Account" "To Account" "Date" "Amount" "Payee") (7 0 5 3244075201 15 "India Chat House") (10 2 0 3244161601 540 "djc") (12 0 7 3244680001 20 "djc") (14 0 4 3244686408 10 "djc") (19 0 7 3302481601 200 "david j cooper") (21 2 0 3302481601 2000 "djc") (23 0 0 3337646401 500 "me") (26 0 0 3337646401 500 "foo") (27 2 0 3574382401 3000 "David Cooper") (28 0 7 3615681601 20 "djc")
402
Common Lisp
.lisp
11
34.545455
62
0.675192
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
1797ed81485cf49d976938bf9e9f90c47070035b6b5f0601918729ac7969bffe
36,277
[ -1 ]
36,278
assembly.lisp
lisp-mirror_gendl/demos/ledger/source/assembly.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language (GDL) project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :ledger) (defparameter *source-dir* (glisp:system-home :ledger)) (define-object assembly () :input-slots ((account-data-file (merge-pathnames "data/accounts.lisp" *source-dir*)) (transaction-data-file (merge-pathnames "data/transactions.lisp" *source-dir*))) :computed-slots ((account-data (let (result) (with-open-file (in (the account-data-file)) (do ((account (read in nil nil) (read in nil nil))) ((null account) (nreverse result)) (push account result))))) (transaction-data (let (result) (with-open-file (in (the transaction-data-file)) (do ((transaction (read in nil nil) (read in nil nil))) ((null transaction) (nreverse result)) (push transaction result))))) (account-indices (mapsend (the accounts) :index)) (transaction-indices (mapsend (the transactions) :index)) (net-worth (the (total-balance :asset/liability))) (profit (- (the (total-balance :income/expense)))) (balances-hash-table (let ((ht (make-hash-table))) (dolist (account (list-elements (the accounts))) (setf (gethash (the-object account index) ht) (the-object account beginning-balance))) (dolist (transaction (list-elements (the transactions)) ht) (decf (gethash (the-object transaction from-account) ht) (the-object transaction amount)) (incf (gethash (the-object transaction to-account) ht) (the-object transaction amount)))))) :objects ((accounts :type 'account :sequence (:indices (mapcar #'first (rest (the account-data)))) :data (find (the-child index) (rest (the account-data)) :key #'first) :current-balance (gethash (the-child index) (the balances-hash-table)) :headings (first (the account-data))) (transactions :type 'transaction :sequence (:indices (mapcar #'first (rest (the transaction-data)))) :data (find (the-child index) (rest (the transaction-data)) :key #'first) :headings (first (the transaction-data)))) :functions ((total-balance (account-class-key) (reduce #'+ (mapsend (remove-if-not #'(lambda(account) (eql (the-object account account-class-key) account-class-key)) (list-elements (the accounts))) :current-balance))) (add-transaction! (&key from-account to-account date amount payee) (when (or (not (member from-account (the account-indices))) (not (member to-account (the account-indices))) (not (numberp amount)) (not (stringp payee)) (not (ignore-errors (decode-universal-time date)))) (error "One or more invalid arguments given to add-transaction!")) (let ((new-index (1+ (if (null (the transaction-indices)) 0 (apply #'max (the transaction-indices)))))) (the transactions (insert! new-index)) ;;(the (transactions new-index)) (the (transactions new-index) (set-slot! :data (list new-index from-account to-account date amount payee)))) (the save-transactions!)) (save-transactions! () (with-open-file (out (the transaction-data-file) :direction :output :if-exists :supersede :if-does-not-exist :create) (print (first (the transaction-data)) out) (dolist (transaction (list-elements (the transactions))) (print (the-object transaction data) out)))) (add-account! (&key name description account-number account-type account-class beginning-balance) (when (or (not (member account-class (list "Asset/Liability" "Income/Expense") :test #'string-equal)) (not (numberp beginning-balance))) (error "One or more invalid arguments given to add-account!")) (let ((new-index (1+ (if (null (the account-indices)) 0 (apply #'max (the account-indices)))))) (the accounts (insert! new-index)) ;;(the (accounts new-index)) (the (accounts new-index) (set-slot! :data (list new-index name description account-number account-type account-class beginning-balance)))) (the save-accounts!)) (save-accounts! () (with-open-file (out (the account-data-file) :direction :output :if-exists :supersede :if-does-not-exist :create) (print (first (the account-data)) out) (dolist (account (list-elements (the accounts))) (print (the-object account data) out)))))) (define-object account () :input-slots (data headings current-balance) :computed-slots ( (name (second (the data))) (description (third (the data))) (account-number (fourth (the data))) (account-type (fifth (the data))) (account-class (sixth (the data))) (account-class-key (make-keyword (string-downcase (the account-class)))) (beginning-balance (seventh (the data))))) (define-object transaction () :input-slots (data headings) :computed-slots ((from-account (second (the data))) (to-account (third (the data))) (date (fourth (the data))) (amount (fifth (the data))) (payee (sixth (the data)))))
6,157
Common Lisp
.lisp
145
35.517241
88
0.653383
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
72ffec224ab46c5b22fea8c8fd95cad4d961d080544e0b77ad6d91dea39bb0e6
36,278
[ -1 ]
36,279
package.lisp
lisp-mirror_gendl/demos/ledger/source/package.lisp
(in-package :gdl-user) (gwl:define-package :ledger (:documentation #.(glisp:system-description :ledger)) (:export #:assembly #:html-assembly))
162
Common Lisp
.lisp
4
34.75
58
0.690789
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
98ce0ffa016251bc9548692b8e4958d106420b957e2c4cb459e8a4be3f84391d
36,279
[ -1 ]
36,280
html.lisp
lisp-mirror_gendl/demos/ledger/source/html.lisp
;; ;; Copyright 2002, 2009 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language (GDL) project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :ledger) (define-object html-assembly (base-ajax-sheet) :objects ((ledger :type 'assembly) (view-accounts :type 'view-accounts :account-sequence (the ledger accounts)) (view-transactions :type 'view-transactions :transaction-sequence (the ledger transactions) :accounts-sequence (the ledger accounts)) (add-transaction :type 'add-transaction :main-sheet self :accounts-sequence (the ledger accounts)) (add-account :type 'add-account :main-sheet self)) :functions ( (write-html-sheet () (let ((plist (the add-transaction query-plist))) (when plist (the ledger (add-transaction! :from-account (read-safe-string (getf plist :from-account)) :to-account (read-safe-string (getf plist :to-account)) :date (iso-to-universal (getf plist :date)) :amount (read-safe-string (getf plist :amount)) :payee (getf plist :payee)))) (the add-transaction (:set-slot! :query-plist nil))) (let ((plist (the add-account query-plist))) (when plist (the ledger (add-account! :name (getf plist :name) :description (getf plist :description) :account-number (getf plist :account-number) :account-type (getf plist :account-type) :account-class (getf plist :account-class) :beginning-balance (read-safe-string (getf plist :beginning-balance))))) (the add-account (:set-slot! :query-plist nil))) (html (:html (:head (:title "Personal Ledger")) (:body (:h2 (:center "Personal Ledger")) (:p (:table (:tr (:td "Net Worth:") ((:td :align :right) (:b (:tt ((:font :color (gethash (if (minusp (the ledger net-worth)) :red :green-lime) *color-table*)) (:princ (number-format (the ledger net-worth) 2))))))) (:tr (:td "Profit/Loss:") ((:td :align :right) (:b (:tt ((:font :color (gethash (if (minusp (the ledger profit)) :red :green-lime) *color-table*)) (:princ (number-format (the ledger profit) 2))))))))) (:p (:ul (:li (the view-accounts (write-self-link :display-string "View Accounts"))) (:li (the view-transactions (write-self-link :display-string "View Transactions"))) (:li (the add-transaction (write-self-link :display-string "Add Transaction"))) (:li (the add-account (write-self-link :display-string "Add Account"))))))))))) (defun adaptive-lessp (item1 item2) (if (and (numberp item1) (numberp item2)) (< item1 item2) (string-lessp (format nil "~a" item1) (format nil "~a" item2)))) (defun adaptive-greaterp (item1 item2) (if (and (numberp item1) (numberp item2)) (> item1 item2) (string-greaterp (format nil "~a" item1) (format nil "~a" item2)))) (define-object view-accounts (base-ajax-sheet) :input-slots (account-sequence) :computed-slots ((accounts (list-elements (the account-sequence))) (accounts-sorted (if (the sort-key) (safe-sort (the accounts) (ecase (the sort-order) (:ascending #'adaptive-lessp) (:descending #'adaptive-greaterp)) :key #'(lambda(account) (the-object account (evaluate (the sort-key))))) (the accounts))) (sort-key nil :settable) (sort-order :ascending :settable) (headings (the-object (first (the accounts)) headings)) (main-sheet-body (with-cl-who-string () (when gwl:*developing?* (str (the development-links))) (:h2 (:center "Account Listing")) (:p (the (:write-back-link :display-string "Home"))) (:p (str (the main-section main-div))) (:p (the (:write-back-link :display-string "Home")))))) :functions ((set-sort-key! (&key sort-key) (if (eql sort-key (the sort-key)) (the (set-slot! :sort-order (ecase (the sort-order) (:ascending :descending) (:descending :ascending)))) (the (set-slot! :sort-key sort-key))))) :objects ((main-section :type 'sheet-section :inner-html (with-cl-who-string () (:p ((:table :bgcolor :black) ((:tr :bgcolor :yellow) (dolist (heading (append (rest (the headings)) (list "Current Balance"))) (let ((ajax-call (the (gdl-ajax-call :function-key :set-sort-key! :arguments (list :sort-key (make-keyword (format nil "~(~a~)" (glisp:replace-regexp heading " " "-")))))))) (htm (:th ((:span :onclick ajax-call :style "color: blue; cursor: pointer;") (str heading))))))) (dolist (account (the accounts-sorted)) (htm ((:tr :bgcolor (gethash :grey-light-very *color-table*)) (dolist (slot (list :name :description :account-number :account-type :account-class :beginning-balance :current-balance)) (let* ((raw-value (the-object account (evaluate slot))) (value (case slot ((:beginning-balance :current-balance) (number-format raw-value 2)) (otherwise raw-value)))) (htm ((:td :align (case slot ((:beginning-balance :current-balance) :right) (otherwise :left))) (case slot ((:beginning-balance :current-balance) (htm (:tt (fmt "$~$" value)))) (otherwise (htm (str value))))))))))))))))) (define-object view-transactions (base-ajax-sheet) :input-slots (transaction-sequence accounts-sequence) :computed-slots ((transactions (list-elements (the transaction-sequence))) (headings (the-object (first (the transactions)) headings)) (main-sheet-body (with-cl-who-string () (:h2 (:center "Transaction Listing")) (:p (the (:write-back-link :display-string "Home"))) (:p (str (the main-section main-div))) (:p (the (:write-back-link :display-string "Home")))))) :functions ((delete-transaction! (index) (the ledger transactions (delete! index)) (the ledger save-transactions!))) :objects ((delete-buttons :type 'button-form-control :sequence (:size (length (the transactions))) :label "Delete" :onclick (the (gdl-ajax-call :function-key :delete-transaction! :arguments (list (the-object (nth (the-child index) (the transactions)) index))))) (main-section :type 'sheet-section :inner-html (with-cl-who-string () ((:table :bgcolor :black) ((:tr :bgcolor :yellow) (dolist (heading (rest (the headings))) (htm (:th (str heading)))) (:th "")) (let ((count -1)) (dolist (transaction (the transactions)) (incf count) (htm ((:tr :bgcolor (gethash :grey-light-very *color-table*)) (dolist (slot (list :from-account :to-account :date :amount :payee )) (let* ((raw-value (the-object transaction (evaluate slot))) (value (case slot ((:from-account :to-account) (the :accounts-sequence (get-member raw-value) :name)) (:date (iso-date raw-value)) (:amount (number-format raw-value 2)) (otherwise raw-value)))) (htm ((:td :align (case slot (:amount :right) (otherwise :left))) (case slot (:amount (htm (:tt (fmt "$~$" value)))) (otherwise (htm (str value)))))))) (:td (str (the (delete-buttons count) form-control-string)))))))))))) (define-object add-transaction (base-ajax-sheet) :input-slots (accounts-sequence main-sheet) :computed-slots ((respondent (the main-sheet))) :functions ((write-html-sheet () (html (:html (:head (:title "Add Transaction")) (:body (:h2 (:center "Add Transaction")) (:p (the (:write-back-link :display-string "Home"))) (with-html-form () (:p ((:table :bgcolor :black) (:tr ((:td :bgcolor :yellow) "From Account") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:select :name :from-account) (mapcar #'(lambda(account) (html ((:option :value (the-object account index)) (:princ (the-object account name))))) (list-elements (the accounts-sequence)))))) (:tr ((:td :bgcolor :yellow) "To Account") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:select :name :to-account) (mapcar #'(lambda(account) (html ((:option :value (the-object account index)) (:princ (the-object account name))))) (list-elements (the accounts-sequence)))))) (:tr ((:td :bgcolor :yellow) "Date") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:input :type :text :name :date :size 12 :value (iso-date (get-universal-time)))))) (:tr ((:td :bgcolor :yellow) "Amount") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:input :name :amount :type :text :size 15)))) (:tr ((:td :bgcolor :yellow) "Payee") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:input :name :payee :type :text :size 30)))))) (:p ((:input :type :submit :name :add-transaction :value " Add! ")))))))))) (define-object add-account (base-ajax-sheet) :input-slots (main-sheet) :computed-slots ((respondent (the main-sheet))) :functions ((write-html-sheet () (html (:html (:head (:title "Add Account")) (:body (:h2 (:center "Add Account")) (:p (the (:write-back-link :display-string "Home"))) (with-html-form () (:p ((:table :bgcolor :black) (:tr ((:td :bgcolor :yellow) "Name") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:input :type :text :name :name :size 25)))) (:tr ((:td :bgcolor :yellow) "Description") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:input :type :text :name :description :size 40)))) (:tr ((:td :bgcolor :yellow) "Number") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:input :type :text :name :account-number :size 25)))) (:tr ((:td :bgcolor :yellow) "Type") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:input :type :text :name :account-type :size 25)))) (:tr ((:td :bgcolor :yellow) "Class") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:select :name :account-class :size 1) ((:option :value "Asset/Liability") "Asset/Liability") ((:option :value "Income/Expense") "Income/Expense")))) (:tr ((:td :bgcolor :yellow) "Beginning Balance") ((:td :bgcolor (gethash :green-spring *color-table*)) ((:input :type :text :name :beginning-balance :size 15 :value 0)))))) (:p ((:input :type :submit :name :add-account :value " Add! ")))))))))) (defun iso-to-universal (iso-date) (let ((year (read-safe-string (subseq iso-date 0 4))) (month (read-safe-string (subseq iso-date 5 7))) (date (read-safe-string (subseq iso-date 8 10)))) (encode-universal-time 1 0 0 date month year))) (defun iso-date (universal-time) (multiple-value-bind (seconds minutes hours date month year) (decode-universal-time universal-time) (declare (ignore seconds minutes hours)) (format nil "~a-~2,,,'0@a-~2,,,'0@a" year month date))) (publish :path "/ledger" :function #'(lambda(req ent) (gwl-make-part req ent "ledger:html-assembly")))
12,662
Common Lisp
.lisp
303
33.79868
84
0.597633
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
090116ab519ab7dad6c12409184957f510d18994f8e98c4987fb838e1b1ebbc7
36,280
[ -1 ]
36,281
zzinit.lisp
lisp-mirror_gendl/demos/ledger/source/zzinit.lisp
(in-package :ledger) (defvar *settings* (list (list '*source-dir* *source-dir* #'(lambda() (or (and *source-dir* (probe-file *source-dir*)) (and glisp:*gdl-program-home* (probe-file (merge-pathnames "ledger-data/" glisp:*gdl-program-home*))) (and glisp:*gdl-program-home* (probe-file (merge-pathnames "data/" glisp:*gdl-program-home*))) (warn "~%Ledger data not found in source directory or parent of program directory.~%")))))) (defun initialize () (let (anything-changed?) (setq anything-changed? (glisp:set-settings *settings*)) anything-changed?))
628
Common Lisp
.lisp
14
38.428571
99
0.652755
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
172be09cbfbdafc525da11a9614d5549ed8fd9944d5a3915e17470ffa1d53357
36,281
[ -1 ]