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,071 | package.lisp | lisp-mirror_gendl/base/source/package.lisp | ;;
;; Copyright 2002, 2007, 2013 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 :common-lisp-user)
(defpackage :gendl-boot (:export #:system-description #:system-home))
(eval-when (:compile-toplevel :load-toplevel :execute)
#-(or allegro lispworks sbcl ccl abcl clisp) (error "
D'oh! GenDL is not yet supported on ~a. If you would like to try porting it, start with this file,
gdl/base/common/genworks.lisp.
Also, PortableAllegroserve is needed for the web framework.
If you are interested in this effort we would love to hear from you at [email protected].
" (lisp-implementation-type))
;;
;; Copied here from ./genworks.lisp for bootstrapping purposes.
;;
(defun gendl-boot:system-description (system-designator &optional (errorp t))
(let (description (home (gendl-boot:system-home system-designator errorp)))
(when home
(let ((description-file (merge-pathnames "description.isc" home)))
(when (probe-file description-file)
(setq description
(with-open-file (in description-file) (read in))))))
(or description (format nil "~a Subsystem" system-designator))))
(defun gendl-boot:system-home (system-designator &optional (errorp t))
(if (find-package :asdf)
(funcall (read-from-string "asdf:system-source-directory") system-designator)
(when errorp (error "~&glisp:system-home was called, but cannot function because asdf is not loaded.~%")))))
(defpackage :gendl
;;
;; FLAG -- intention is to change this to :base eventually ---
;; "gendl" is name of overall system.
;;
(:nicknames :gdl :genworks :base)
(:documentation #.(gendl-boot:system-description :base))
(:use :common-lisp)
(:shadow #:the)
(:export #:%bottom-margin%
#:%left-margin%
#:%paper-height%
#:%paper-width%
#:%projection-vector%
#:%view-plane-inverse%
#:%view-plane-normal%
#:*%format%*
#:*allowed-part-documentation-keywords*
#:*bias-to-double-float?*
#:*color-table*
#:*color-table-decimal*
#:*colors-default*
#:*compile-circular-reference-detection?*
#:*compile-dependency-tracking?*
#:*compile-documentation-database?*
#:*compile-for-dgdl?*
#:*compile-source-code-database?*
#:*compile-with-dependency-recording?*
#:*current-version*
#:*curve-chords*
#:*display-controls*
#:*dummy-version*
#:*ensure-lists-when-bashing?*
#:*error-on-reserved-words?*
#:*force-restore-slot-default?*
#:*override-non-settables?*
#:*gdl-init-functions*
#:*gendl-version*
#:*gendl-patch-level*
#:*ghostscript-path*
#:*gs-path*
#:*sort-children?*
#:*load-documentation-database?*
#:*load-source-code-database?*
#:*out-of-bounds-sequence-reference-action*
#:*paper-size-plist*
#:*paper-size-table*
#:*patch-fasls*
#:*patches-root-dir-default*
#:*recompile-gdl?*
#:*remember-previous-slot-values?*
#:*report-gdl-redefinitions?*
#:*reserved-word-protected-packages*
#:*retain-object-identity-on-type-change?*
#:*rgb-cube-colors*
#:*run-with-circular-reference-detection?*
#:*run-with-dependency-recording?*
#:*run-with-dependency-tracking?*
#:*skin*
#:*stream*
#:*ui-server*
#:*undeclared-parameters-enabled?*
#:*zero-epsilon*
#:+kappa+
#:+phi+
#:2pi
#:add-godparent
#:alist2plist
#:always
#:append-elements
#:assembly-leaf-mixin
#:assembly-node-mixin
#:base-format
#:base-rule-object
#:base-spec-sheet
#:binary-search
#:cl
#:cl-dir
#:cl-lite
#:clean
#:clean-dir
#:copy-files-to
#:cyclic-nth
#:decode-for-http
#:defaulting
;;#:defcompanion
#:define-color-set
#:define-colored-icon
#:define-format
#:define-icon
#:define-lens
#:define-object
#:define-object-amendment
#:define-object-documentation
#:define-object-macro-toplevel
#:define-package
#:define-skin
#:define-view
#:definition-tree
;;#:defpart
;;#:defwriter
#:distribute
#:distribute-dir
#:div
#:dumplisp
#:dump-image
#:encode-for-http
#:ensure-list
#:evaluate
#:evaluate-object
#:evaluate-if-handled
#:expandit
#:find-messages-used-by
#:find-messages-which-use
#:flatten
#:format-slot
#:fround-to-nearest
#:gdl-app
#:gdl-class
#:gdl-format-class
#:gdl-format-symbol
#:gdl-object-symbol
#:gdl-object-symbol
#:gdl-remote
#:gdl-skin-class
#:get-version
#:half
#:ignore-errors-with-backtrace
#:index-filter
#:inverted-readtable
#:iso-8601-date
#:universal-time-from-iso-8601
#:universal-time-to-plist
#:keywordize-plist
#:lastcar
#:least
;;#:let-streams
#:list-elements
#:list-hash
#:list-of-numbers
#:*allow-nil-list-of-numbers?*
#:list-of-n-numbers
#:lookup-color
#:load-glime
#:load-quicklisp
#:load-hotpatches
#:*quicklisp-home*
#:make-canonical-part
#:make-keyword
#:ensure-keyword
#:make-gdl-app
#:make-keyword-sensitive
#:make-object
#:make-part
#:make-self
#:mapsend
#:maptree
#:match-regexp*
#:max-of-elements
#:merge-common-keys
#:message-popup
#:min-max-search
#:min-of-elements
#:most
#:near-to?
#:near-zero?
#:never
#:null-object
#:null-part
#:number-format
#:number-round
#:one-line
#:peruse-file
#:pi/2
#:plist-keys
#:plist-values
#:print-hash
#:print-messages
#:print-variables
#:quantification
#:query-collect
#:query-license-server
#:read-safe-string
#:read-snapshot
#:readable-expression
;;#:record-source-file
#:register-init-function
#:remote-object
#:remove-plist-key
#:remove-plist-entry
#:remove-plist-keys
#:replace-substring
#:restore-ui-object
#:reset-glm
#:retitle-emacs
#:retrieve
#:rgb-cube-colors
#:round-to-nearest
#:safe-float
#:safe-sort
#:self
#:send
#:series
#:set-format-slot
#:set-self
#:split
#:standard-query
#:start-gendl!
#:status-message
#:string-append
#:sum-elements
#:tak
#:the
#:the-child
#:the-element
#:the-object
#:theo
#:to-double-float
#:to-single-float
#:traverse-tree
#:twice
#:undefine-object
#:update
#:update-gdl
#:update-gendl
#:vanilla-mixin
#:vanilla-mixin*
#:vanilla-remote
#:version-sequence
#:with-error-handling
#:with-format
#:with-writer
#:with-format-slots
#:with-oracle
#:with-version
#:write-env
#:write-objects
#:write-plist
#:write-the
#:write-the-object
#:xml-reader
#:^2
#:room-report
#:*newspace*
#:*oldspace*
#:*onclick-function*
#:*already-loaded-systems*
#:*loaded-hotpatches*
#:*packages-to-lock*
#:*patch-url-base*
#:*warn-on-invalid-toplevel-inputs?
#:*invalid-aggregate-behavior*
))
#-(or allegro lispworks sbcl ccl abcl ecl clisp) (error "Need package for mop:validate-superclass for currently running lisp.~%")
(defpackage :com.genworks.lisp
(:documentation #.(gendl-boot:system-description :glisp))
(:use :common-lisp)
(:shadow #:intern)
(:nicknames :glisp)
(:import-from #+(or allegro abcl) :mop #+lispworks :hcl #+sbcl :sb-mop #+ccl :ccl #+(or ecl clisp) :clos
#:validate-superclass)
(:export
;;
;; Some implemented in gendl/base/source/genworks.lisp, the rest
;; in gendl/glisp/source/genworks.lisp.
;;
;; FLAG -- alphabetize all these here in this package export list.
;;
#:*external-text-format*
#:*gdl-home*
#:*gendl-home*
#:*gdl-program-home*
#:*gendl-program-home*
#:*genworks-source-home*
#:*gendl-source-home*
#:*gdl-source-home*
#:basic-command-line-arguments
#:begin-redefinitions-ok
#:current-directory
#:define-constant
#:direct-superclasses
#:direct-superclass-names
#:display-startup-banner
#:end-redefinitions-ok
#:ensure-string
#:eql-specializer
#:executable-homedir-pathname
#:featurep
#:find-feature-version
#:gl-class-name
#:gl-method-specializers
#:hex-string-to-integer
#:intern
#:make-sans-value-equalp-hash-table
#:make-sans-value-hash-table
#:make-weak-hash-table
#:make-versioned-features
#:set-default-character-width
#:set-default-float-format
#:set-default-package
#:set-defpackage-behavior
#:set-local-compiler-tweaks
#:set-features
#:set-settings
#:set-window-titles
#:sexpr-from-file
#:source-pathname
#:system-description
#:system-home
#:set-genworks-source-home-if-known
#:upcase
#:validate-superclass
#:with-definition-unit
#:without-package-variance-warnings
#:w-o-interrupts
#:with-lock-held
#:make-lock
#:xref-off
#:xref-on
#:*fasl-extension*
#:concatenate-fasls
#:directory-list
#:file-directory-p
#:run-command
#:temporary-folder
#:*temporary-folder-function*
#:*utf-16-ef*
#:temporary-file
#:find-gs-path
#:get-pid
#:run-gs
#:set-gs-path
#:run-program
#:run-shell-command
#:*enable-utf8?*
#:*base64-encode-func*
#:*base64-decode-func*
#:class-slots
#:gc-full
#:get-backtrace
#:initialize-multiprocessing
#:local-port
#:match-regexp
#:patches-dir
#:process-run-function
#:remote-host
#:local-host
#:replace-regexp
#:room-report
#:slot-definition-name
#:snap-folder
#:socket-bytes-written
#:split-regexp
#:with-heuristic-case-mode
#:with-timeout-sym
#:with-timeout
#:without-redefinition-warnings
#:close-old-areas
#:open-old-areas
#:get-mem-info
#:gc-scavenge
#:copy-directory
#:copy-file
#:delete-directory-and-files
#:dump-memory
#:implementation-identifier
#:next-datestamp
#:autoloaded-packages
#:package-documentation
#:function-documentation
#:variable-documentation
#:parse-xml
#:rsync
))
(defpackage :geom-base
(:use :common-lisp :gdl)
(:shadowing-import-from :gdl #:the)
(:documentation #.(gendl-boot:system-description :geom-base))
(:export #:keyed-transform*vector
#:with-translated-state
#:raphael
#:svg
#:*raphael-translation*
#:*svg-translation*
#:make-vector
#:make-point
#:apply-make-point
#:merge-display-controls
#:*nominal-x-vector*
#:*nominal-y-vector*
#:*nominal-z-vector*
#:*nominal-x-vector-r*
#:*nominal-y-vector-r*
#:*nominal-z-vector-r*
#:*trimetric-normal-vector*
#:*trimetric-normal-vector-left*
#:*trimetric-normal-vector-right-rear*
#:*trimetric-normal-vector-left-rear*
#:*left-handed-transform?*
#:+lh-identity-matrix+
#:+nominal-origin+
#:*standard-views*
#:point-expression
#:+postnet-bits+
#:*hash-transforms?*
#:get-x
#:get-y
#:get-z
#:get-w
#:get-u
#:get-v
#:determinant
#:subtract-vectors
#:add-vectors
#:3d-distance
#:scalar*vector
#:matrix*vector
#:transpose-matrix
#:multiply-matrices
#:dot-vectors
#:alignment
#:make-transform
#:angle-between-vectors-d
#:angle-between-vectors
#:unitize-vector
#:orthogonal-component
#:same-direction-vectors?
#:parallel-vectors?
#:reverse-vector
#:cross-vectors
#:length-vector
#:zero-vector?
#:degree
#:radians-to-degrees
#:radians-to-grads
#:translate-along-vector
#:array-to-list
#:coincident-point?
#:projected-vector
#:rotate-point-d
#:rotate-point
#:rotate-vector
#:rotate-vector-d
#:inter-circle-sphere
#:inter-line-sphere
#:inter-line-plane
#:inter-line-line
#:translate
#:create-obliqueness
#:proj-point-on-line
#:pythagorize
#:roll
#:rotation
#:transform-and-translate-point
#:transform-numeric-point
#:quaternion-to-rotation
#:quaternion-to-matrix
#:matrix-to-quaternion
#:matrix-to-rotation
#:normalize-quaternion
#:degrees-to-radians
#:acosd
#:asind
#:atand
#:midpoint
#:between?
#:curve-parameter-<
#:roughly-aligned-vectors?
#:distance-to-line
#:equi-space-points
#:sort-points-along-vector
#:bounding-box-from-points
#:flatten-lines
#:flatten-curves
#:point-on-plane?
#:point-on-vector?
#:arc
#:base-object
#:base-coordinate-system
#:base-geometry-object
#:bezier-curve
#:box
#:bbox
#:c-cylinder
#:circle
#:cone
#:cylinder
#:ellipse
#:global-filleted-polygon-projection
#:global-filleted-polyline
#:global-polygon-projection
#:ifs-output-mixin
#:global-polyline
#:graph
#:l-line
#:null-geometric-object
#:outline-specialization-mixin
#:point
#:route-pipe
#:sphere
#:spherical-cap
#:torus
#:cut-cylinder ;;do later
#:filleted-polyline ;; do later
#:line ;;do later
#:point
#:polyline ;; do later
#:polygon-projection ;;do later
#:points-display
#:note
#:text-block
#:text-lines
#:typeset-block
#:typeset-blocks
#:base-drawing
#:base-view
#:document
#:horizontal-dimension
#:parallel-dimension
#:vertical-dimension
#:label
#:linear-dimension
#:leader-line
#:dxf
#:obj
#:pdf-multipage
#:pdf
#:pdf-raw
#:png
#:jpeg
#:vrml
#:x3d
#:scad
#:vector-graphics
#:pie-chart
#:fillet
#:constrained-fillet
#:constrained-line
#:constrained-arc
#:*gs-text-alpha-bits*
#:*gs-graphics-alpha-bits*
;;
;; Implemented in gdl/geom-base/annotations/source/
;;
#:angular-dimension
#:sample-drawing
#:generate-sample-drawing
#:center-line
#:*break-leaders?*
#:print-document
;;
;; Implemented in gdl/geom-base/text/source/
;;
#:general-note
#:text-line
;;
;;
;; FLAG -- consider exporting these if requested.
;;
;;#:3d-vector-to-array
;;#:array-to-3d-vector
;;
;; types and predicates
;;
#:3d-point?
#:3d-vector?
#:3d-point
#:3d-vector
#:3d-point-p
#:3d-vector-p
))
(defpackage :gdl-toplevel (:use))
(defpackage :gdl-rule (:size 25) (:use)
(:export #:%not-handled% #:write-env #:write-of #:%unbound%))
(defpackage :gdl-slots (:size 10000) (:use) (:export))
(defpackage :gdl-inputs (:size 10000) (:use) (:export))
(defpackage :gdl-trickle-downs (:use) (:export))
(defpackage :gdl-acc (:size 10000) (:use) (:export))
(defpackage :gdl-format (:use) (:export))
(defpackage :gdl-output (:use) (:export))
(defpackage :surf
(:shadowing-import-from :gdl #:the)
(:use :common-lisp :gdl :geom-base)
(:documentation #.(gendl-boot:system-description :surf))
(:shadow #:step)
(:export #:make-geometry-kernel
#:*geometry-kernel*
#:*finalize-lofted-surfaces?*
#:*chain-beziers-for-display?*
#:curve
#:iso-curve
#:trimmed-curve
#:b-spline-curve
#:circular-curve
#:circular-surface
#:arc-curve
#:elliptical-curve
#:linear-curve
#:fitted-curve
#:planar-offset-curve
;;#:fillet
#:projected-curve
#:approximated-curve
#:silhouette-curves
#:dropped-curve
#:surface
#:b-spline-surface
#:extended-surface
#:offset-surface
#:offset-solid
#:shelled-solid
#:manifold-solid
#:normally-projected-curve
#:fitted-surface
#:coons-surface
#:surface-knot-reduction
#:joined-surfaces
#:compatible-surfaces
#:compatible-curves
#:extended-curve
#:lofted-surface
#:ruled-surface
#:test-fitted-surface
#:spherical-surface
#:revolved-surface
#:revolved-surfaces
#:planar-surface
#:rectangular-surface
#:trimmed-surface
#:approximated-subsurface
#:basic-surface
#:split-surface
#:brep
#:edge
#:face
#:iges-reader
#:native-reader
#:brep-reader
#:step-reader
#:composed-curve
#:subdivided-curve
#:composed-curves
#:decomposed-curve
#:decomposed-curves
#:planar-section-curve
#:planar-section-curves
#:global-filleted-polyline-curves
#:global-filleted-polyline-curve
#:planar-contour-surface
#:transformed-curve
#:boxed-curve
#:boxed-surface
#:transformed-surface
#:transformed-solid
#:stitched-solid
#:extruded-solid
#:blended-solid
#:get-3d-point-of
#:get-parameter-of
#:get-other-parameter-of
#:get-uv-point-of
#:get-point-on-surface
#:get-point-on-curve
#:get-point-on-other-curve
#:%get-point-on-surface
#:%get-point-on-curve
#:iges #:native #:stl
#:step
#:box-solid
#:cone-solid
#:cylinder-solid
#:separated-solid
#:subtracted-solid
#:merged-solid
#:validated-solid
#:united-solid
#:intersected-solid
#:swept-solid
#:brep-intersect
#:brep-intersect?
#:regioned-solid
#:merged-brep
#:general-sweep
#:normal-sweep
#:edge-blend-surface
#:with-pinned-values
#:pin-value-to-range
#:fitted-conic
#:*3d-approximation-tolerance-default*
#:*boolean-operation-tolerance-default*
#:*approximation-tolerance-factor*
#:*brep-tolerance-default*
#:*angle-tolerance-radians-default*
#:*display-tolerance*
#:*3d-tolerance-default*
#:*brep-wireframe-tessellation?*
#:*curve-tessellation?*
#:*crease-angle-default*
#:*output-units-default*
#:*isos-default*
#:*brep-isos-default*
#:*brep-vrml-timeout*
#:*nurbs-to-beziers-timeout*
#:*boolean-allow-multiple-regions?*
#:*boolean-error-on-invalid-brep?*
#:iwbrep-sew-and-orient
#:test-b-spline-surface
#:normalized-curve
#:surf-grid-points
#:closed-boolean-operation
#:closed-boolean-separate-operation
#:global-brep-brep-solve
#:non-rational-curve
#:spiral-curve
#:get-faces-from-edge
#:*tess-min-number-of-segments*
#:*tess-max-3d-edge-factor*
#:*tess-min-parametric-ratio*
#:*tess-max-chord-height*
#:*tess-max-angle-degrees*
#:*tess-min-3d-edge*
#:*tess-min-edge-ratio-uv*
#:*tess-max-aspect-ratio*))
(defmacro gdl:define-package (name &rest body)
`(defpackage ,name
(:use :common-lisp :gdl :geom-base :surf)
(:shadowing-import-from :gdl #:the)
(:shadowing-import-from :gdl #:dumplisp)
(:shadowing-import-from :surf #:step)
,@body))
(gdl:define-package :gdl-user)
;;
;; FLAG -- stop using all these library packages in here!
;;
(eval-when (:compile-toplevel :load-toplevel :execute)
(gdl:define-package :gwl
;;
;; FLAG moved this to a (use-package ...) in
;; gdl/gwl/source/genworks.lisp (until we can clean them
;; entirely)
;;
;;(:use :net.aserve :net.aserve.client :net.uri :net.html.generator :cl-who)
(:documentation #.(gendl-boot:system-description :gwl))
(:shadow #:define-package)
(:export
#:define-package
#:remote-object
#:*aserve-port*
#:*aserve-listeners*
#:*aserve-start-args*
#:*req*
#:*ent*
#:*html-referrer*
#:*instance-hash-table*
#:*instance-finalizers*
#:*max-node-depth*
#:*developing?*
#:*mime-file-types*
#:*max-id-value*
#:*server*
#:*query-plist*
#:*field-plist*
#:*ssl-server*
#:*adsense-code*
#:*break-on-set-self?*
#:*jump-to-toplevel-on-set-self?*
#:*process-cookies?*
#:*static-home*
#:announce-server-port
#:encode-root-path
#:base-html-sheet
#:skeleton-ui-element
#:sheet-section
#:session-control-mixin
#:base-html-graphics-sheet
#:color-palette
#:crawl
#:html-submit-button
#:html-button
#:html-checkbox
#:html-radio-button
#:html-select-choices
#:html-file
#:html-multi-line-text
#:html-string
#:html-password
#:html-title
#:html-anchor
#:html-cell
#:html-row
#:html-table
#:html-static-text
#:untagify
#:make-new-session-id
#:html-format
#:html-format
;;#:define-package
#:my
#:my-child
#:from-my
#:my-object
#:defpage
#:root-path-to-query-arg
#:query-arg-to-root-path
#:gwl-make-part
#:gwl-make-object
#:replace-substring
#:custom-base-html-sheet-mixin
#:fix-lhtml
#:start-log-maker
#:clear-log-buffer
#:*log-report-buffer*
#:pdf-output-sheet
#:graphics-preferences
#:application-mixin
#:node-mixin
#:gwl-rule-object
#:*js-incremental-search*
#:html-form
#:form-mixin
#:clear-all-instances
#:clear-instance
#:with-html-form
#:prepend-url-depth
#:publish-shared
#:*publishers*
#:publish-uris
#:with-all-servers
#:web-drawing
#:infinite
#:base64-decode-safe
#:base64-encode-safe
#:base64-decode-list
#:base64-encode-list
#:start-gwl
;;
;; FLAG -- test this in 1575 build
;;
;;#:update-gdl
;;#:*patch-fasls*
;;
;;
;;
#:base-form-control
#:button-form-control
#:checkbox-form-control
#:radio-form-control
#:menu-form-control
#:text-form-control
#:number-form-control
#:password-form-control
#:file-form-control
#:hidden-form-control
#:object-form-control
#:grid-form-control
#:email-form-control
#:encode-for-ajax
#:decode-from-ajax
#:form-element-processor
#:*clicked-x*
#:*clicked-y*
;;
;; Ajax stuff
;;
#:base-ajax-sheet
#:base-ajax-graphics-sheet
#:*standard-ajax-javascript*
#:*ajax-timeout*
#:*bypass-security-check?*
#:with-cl-who
#:with-cl-who-string
#:with-htm
#:publish-gwl-app
#:publish-string-content
)))
(defpackage :gwl-graphics
(:use :common-lisp)
(:documentation #.(gendl-boot:system-description :gwl-graphics)))
(gdl:define-package :enterprise (:export #:gdl-app #:make-gdl-app #:*newspace* #:*oldspace*))
(gdl:define-package :glm (:export #:assembly))
| 25,815 | Common Lisp | .lisp | 924 | 20.08658 | 129 | 0.579871 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 37b852a51f2a0951779ed840164df004fe2fef80a5f607d2053645bd1447033d | 36,071 | [
-1
] |
36,072 | syntax-checker.lisp | lisp-mirror_gendl/base/source/syntax-checker.lisp | (in-package :gdl)
(defparameter *on-syntax-error* :warn "Keyword symbol. Can be either :warn or :error.")
(define-condition syntax-error (error)
((text :initarg :text :reader text)))
(defun syntax-error (name token message-key message)
(let ((text (format nil "Syntax error for class ~s.~%Offending token: ~s~%~a: ~a." name token message-key message)))
(ecase *on-syntax-error*
(:warn (warn text))
(:error (error 'syntax-error :text text)))))
(defun check-floating-string (name form)
"check for special case in which documentation isn't followed by symbol spec"
(when (stringp (first (last form)))
(syntax-error name (first (last form)) "Problem" "documentation string isn't followed by any message symbol")))
(defun check-form (name form predicate grammar)
"general function that, given a predicate, validates all tokens in a slot declaration form"
(dolist (token form)
(if (not (funcall predicate token))
(syntax-error name token "Valid Grammar" grammar))))
(defun check-input-slots (name form)
"Void. :input-slots grammar:
<form> = :input-slots (<token>*)
<token> = <string> | <symbol> | (<string>* <symbol> <expression>+ <behavior>*)
<behavior> = :settable | :defaulting
Also check for special case in which only strings without a symbol following."
(when form
(let ((behavior '(:settable :defaulting))
(grammar "
<form> = :input-slots (<token>*)
<token> = <string> | <symbol> | (<string>* <symbol> <expression>+ <behavior>*)
<behavior> = :settable | :defaulting"))
(flet ((valid-token (token)
(or (symbolp token)
(stringp token)
(and (consp token)
(let ((token (strip-strings token)))
(and (symbolp (first token))
;; RvD: this check still allows duplicate keys in tail of cons
(every
#'(lambda (token*) (member token* behavior))
(rest (rest token)))))))))
(check-form name form #'valid-token grammar)
(check-floating-string name form)
))))
(defun check-computed-slots (name form)
"Void. :computed-slots grammar:
<form> = :computed-slots (<token>*)
<token> = <string> | (<string>* <symbol> <expression>+ <behavior>+)
<behavior> = :settable | :uncached
Also check for special case in which only strings without a symbol following."
(when form
(let ((behavior '(:settable :uncached))
(grammar "
<form> = :computed-slots (<token>*)
<token> = <string> | (<string>* <symbol> <expression>+ <behavior>*)
<behavior> = :settable | :uncached"))
(flet ((valid-token (token)
(or (stringp token)
(and (consp token)
(let ((token (strip-strings token)))
(and (symbolp (first token))
;; RvD: unlike :input-slots, :computed-slots only allows one behavior keyword
;; RvD: otherwise GDL compiler throws warnings.
(or (not (rest (rest token)))
(and (= (length token) 3)
(member (third token) behavior)))
))))))
(check-form name form #'valid-token grammar)
(check-floating-string name form)
))))
(defun check-objects (name form &optional (hidden nil))
"Void. :hidden-objects and :objects grammar:
<form> = (hidden-):objects (<token>*)
<token> = (<string>* <symbol> <rule>*)
<rule> = <keyword> <expression>"
(when form
(let ((grammar (format nil "
<form> = :~aobjects (<token>*)
<token> = (<string>* <symbol> <rule>*)
<rule> = <keyword> <expression>" (if hidden "hidden-" ""))))
(flet ((valid-token (token)
(and (consp token)
(let ((token (strip-strings token)))
(and (symbolp (first token))
;; plist is already checked by define-object internals, but do it here anyway
(or (and (evenp (length (rest token)))
(every #'keywordp (plist-keys (rest token))))
(syntax-error name (rest token) "Problem" (format nil "Unvalid plist for slot ~s" (first token)))
t)
)))))
(check-form name form #'valid-token grammar)
))))
(defun check-functions (name form &optional (methods t))
"Void. Checks :functions or :methods grammar according to following BNF:
<form> = :functions | :methods (<token>*)
<token> = (<string>* <symbol> <behavior>+ <list> <body>)
<behavior> = :cached | :cached-eql | :cached-= | :cached-eq | :cached-equal | :cached-equalp"
(when form
(let ((grammar (format nil "
<form> = :~a (<token>*)
<token> = (<string>* <symbol> <behavior>+ <list> <body>*)
<behavior> = :cached | :cached-eql | :cached-= | :cached-eq | :cached-equal | :cached-equalp"
(if methods "methods" "functions")))
(behavior '(:cached :cached-eql :cached-= :cached-eq :cached-equal :cached-equalp)))
(flet ((valid-token (token)
(and (consp token)
(let ((token (strip-strings token)))
(and (symbolp (first token))
(or (listp (second token))
(and (member (second token) behavior)
(listp (third token)))))))))
(check-form name form #'valid-token grammar)))))
(defun check-trickle-down-slots (name form)
":functions | :methods grammar:
<form> = :trickle-down-slots (<symbol>*)
"
(when form
(let ((grammar "<form> = :trickle-down-slots (<symbol>*)"))
(if (not (and (consp form)
(every #'symbolp form)))
(syntax-error name form "Valid Grammar" grammar)))))
(defun check-query-slots (name form)
"unknown what is is"
(declare (ignore name form))
t)
(defun check-documentation (name form)
"plist containing keys :description :author :examples :date :version"
(when form
(let ((valid-keys '(:description :author :examples :date :version)))
(when (not (and (consp form)
(evenp (length form))
(every #'(lambda (key) (member key valid-keys)) (plist-keys form))))
(syntax-error name form "Problem"
(format nil ":documentation is a plist which may contain the following keys: ~a" valid-keys))))))
(defun check-syntax (name
input-slots
computed-slots
objects
hidden-objects
functions
methods
documentation
trickle-down-slots
query-slots)
(check-input-slots name input-slots)
(check-computed-slots name computed-slots)
(check-objects name objects)
(check-objects name hidden-objects t)
(check-functions name functions)
(check-functions name methods t)
(check-trickle-down-slots name trickle-down-slots)
(check-query-slots name query-slots)
(check-documentation name documentation)
)
| 6,439 | Common Lisp | .lisp | 153 | 37.281046 | 118 | 0.650464 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | f5be783b2f0b703953855416d515115d33e9b29ddf4b7a49c3b9b85532d3d2d0 | 36,072 | [
-1
] |
36,073 | utilities.lisp | lisp-mirror_gendl/base/source/utilities.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; 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 :gdl)
(defun plist2pairs (plist)
(when plist
(append (list (list (first plist)
(second plist)))
(plist2pairs (rest (rest plist))))))
(defun plist-keys (plist)
"List of keyword symbols. Returns the keys from a plist.
:arguments (plist \"Plist\")"
(when plist
(cons (first plist)
(plist-keys (rest (rest plist))))))
(defun plist-values (plist)
"List of Lisp objects. Returns the values from a plist.
:arguments (plist \"Plist\")"
(when plist
(cons (second plist)
(plist-values (rest (rest plist))))))
(defun remove-plist-entry (plist key &key (test #'eql))
"Plist. Returns a new plist sans any key/value pairs where the plist key is eql to the given key.
Optionally a different test than #'eql can be specified with the :test keyword argument.
:arguments (plist \"Plist. The source plist.\"
key \"matching key, typically a keyword symbol. The key to target for removal.\")
:&key ((test #'eql) \"predicate equality function taking two arguments. The function to use for matching.\")
:examples (remove-plist-entry (list :a \"a\" :b :a) :a)
"
(mapcan #'(lambda (%key% %val%)
(unless (funcall test key %key%)
(list %key% %val%)))
(plist-keys plist) (plist-values plist)))
(defun remove-plist-key (plist key)
(let (result on-remark?)
(dolist (element plist (nreverse result))
(cond ((eql element key)
(setq on-remark? t))
(on-remark?
(setq on-remark? nil))
(t (push element result))))))
(defun remove-plist-keys (plist keys)
(when plist
(if (null keys) plist
(remove-plist-keys (remove-plist-key plist (first keys)) (rest keys)))))
(defmacro print-variables (&rest vars)
"[Macro] Void. Prints the specified variables and current values to standard output.
:arguments (vars \"unquoted symbols (&rest argument)\")"
`(let (*print-readably*)
(format *trace-output*
,(with-output-to-string(ss)
(write-string "~&" ss)
(mapcar #'(lambda(var)
(format ss "~&~a = ~~s~%" var)) vars)
(write-string "~%" ss))
,@vars)))
(defmacro print-messages (&rest messages)
"[Macro] Void. Prints the specified GDL object messages (i.e. slots) and their current values to standard output.
:arguments (vars \"unquoted symbols (&rest argument)\")"
`(let (,@(mapcar #'(lambda(message)
`(,message (the ,message))) messages))
(print-variables ,@messages)))
(defun string-append (&rest args)
"String. Returns a new string made up of concatenating the arguments.
:arguments
(:&rest (args \"strings\"))
"
(apply #'concatenate 'string args))
(defun ensure-keyword (&rest strings)
(if (and (= (length strings) 1) (keywordp (first strings)))
(first strings)
(apply #'make-keyword strings)))
;;
;; FLAG - consider exporting.
;; Notify CBI, as they have this in their codebase now.
;;
(defparameter *keyword-package* (find-package :keyword))
(defun make-key (item)
(intern (if (numberp item)
(with-output-to-string (str) (princ item str))
item) *keyword-package*))
;;
;;
;;
(defun make-keyword (&rest strings)
"Keyword symbol. Converts given strings to a keyword.
If any of the given arguments is not a string, it will be converted to one with
(format nil \"~a\" string).
:arguments (strings \"&rest Strings\")"
(%make-keyword (apply #'string-append (mapcar #'(lambda(string) (string (%make-keyword string))) strings))))
(defun make-keyword-sensitive (string) (glisp:intern string :keyword))
(defun %make-keyword (string)
(when (not (stringp string)) (setq string (format nil "~a" string)))
(when (and (not (zerop (length string)))
(eql (aref string 0) #\:))
(setq string (subseq string 1)))
(multiple-value-bind (symbol flag)
(glisp:intern (glisp:upcase string) :keyword)
(declare (ignore flag))
symbol))
(defun ensure-list (possible-list)
"List. If argument is not list, returns it in a list. If argument is
a list, returns it unchanged.
:arguments (possible-list \"Lisp object\")"
(if (listp possible-list)
possible-list
(list possible-list)))
(defun all-superclasses (class)
(let ((direct-supers (glisp:direct-superclasses class)))
(remove-duplicates
(append direct-supers
(mapcan #'(lambda(class)
(all-superclasses class)) direct-supers)))))
(defun compare-items (new-cons old-cons)
(destructuring-bind (node1 . message1) new-cons
(destructuring-bind (node2 . message2) old-cons
(and (eq node1 node2) (eq message1 message2)))))
(defparameter *dependency-hash* (glisp:make-weak-hash-table))
(defparameter *run-with-dependency-recording?* nil)
(defparameter *compile-with-dependency-recording?* t)
(defun find-messages-used-by (instance message-key)
"List of pairs of instance/keyword. This returns the list of direct dependants of a given
message in a given instance. Note that this is not recursive; if you want to generate a tree,
then you have to call this recursively yourself.
If you want an easy way to remember the meaning of dependant and dependency:
You have a dependency on caffeine. Your children are your dependants.
"
(let ((message-hash (gethash instance *dependency-hash*)))
(when message-hash (reverse (gethash message-key message-hash)))))
(defun find-dependants (instance message-key)
"List of pairs of instance/keyword. Synonymous with find-messages-used-by."
(find-messages-used-by instance message-key))
(defun find-messages-which-use (instance message-key)
"List of pairs of instance/keyword. This returns the list of direct dependencies of a given
message in a given instance. Note that this is not recursive; if you want to generate a tree,
then you have to call this recursively yourself.
If you want an easy way to remember the meaning of dependant and dependency:
You have a dependency on caffeine. Your children are your dependants.
"
(let ((notify-cons (second (slot-value instance (glisp:intern (string message-key) :gdl-acc)))))
;;
;; FLAG -- might have to normalize this into instance/message
;; pairs if messages are grouped on single instance
;;
(let (result)
(dolist (group notify-cons (nreverse result))
(let ((instance (first group)))
(dolist (message (rest group))
(push (list instance (make-keyword (string message))) result)))))))
(defun find-dependencies (instance message-key)
"List of pairs of instance/keyword. Synonymous with find-messages-which-use."
(find-messages-which-use instance message-key))
(let ((value '+value+ #+nil(gensym)) (need? '+need?+ #+nil (gensym)))
(defmacro with-dependency-tracking ((message-symbol &optional (self-sym 'self)) &rest body)
`(let ((,value (,message-symbol ,self-sym))
;;
;; FLAG - this gets invoked far too often - must analyze this. Also, *root-checking-enabled*
; should result in need defaulting to t, not nil, and the same-tree check being skipped.
;;
(,need? (and *run-with-dependency-tracking?* *notify-cons* *root-checking-enabled?*
;;
;; FLAG -- check that remotes are effectively from same tree as well
;;
(or (and (find-class 'gdl-remote nil) (typep (first *notify-cons*) 'gdl-remote))
(same-tree? ,self-sym (first *notify-cons*))))))
,(when *compile-circular-reference-detection?*
`(when (and *run-with-circular-reference-detection?*
(member (list ,self-sym ',message-symbol) *till-now* :test #'equalp))
(error "Circular reference detected")))
(if (eq (first (ensure-list ,value)) 'gdl-rule::%unbound%)
(progn (setq ,value (list (let* ,(remove nil
(list (when *compile-dependency-tracking?*
`(*notify-cons* (when *run-with-dependency-tracking?*
(list ,self-sym ',message-symbol))))
(when *compile-circular-reference-detection?*
`(*till-now* (when *run-with-circular-reference-detection?*
(cons (list ,self-sym ',message-symbol)
*till-now*))))))
,@body)
(when ,need? (list (copy-list *notify-cons*)))))
(if (not (eql (first ,value) 'gdl-rule:%not-handled%))
(setf (,message-symbol ,self-sym) ,value)
;;(without-interrupts (setf (,message-symbol ,self-sym) ,value))
(progn (setq ,need? nil)
(not-handled ,self-sym ',message-symbol))))
(when ,need? (add-notify-cons *notify-cons* ,value ,self-sym ',message-symbol)))
(first ,value))))
;;
;; FLAG - this is current
;;
#+nil
(let ((value (gensym)) (need? (gensym)))
(defmacro with-dependency-tracking ((message-symbol &optional (self-sym 'self)) &rest body)
`(let ((,value (,message-symbol ,self-sym))
(,need? (and *run-with-dependency-tracking?* *notify-cons* *root-checking-enabled?*
;;
;; FLAG -- check that remotes are effectively from same tree as well
;;
(or (and (find-class 'gdl-remote nil) (typep (first *notify-cons*) 'gdl-remote))
(same-tree? ,self-sym (first *notify-cons*))))))
,(when *compile-circular-reference-detection?*
`(when (and *run-with-circular-reference-detection?*
(member (list ,self-sym ',message-symbol) *till-now* :test #'equalp))
(error "Circular reference detected")))
(if (eq (first (ensure-list ,value)) 'gdl-rule::%unbound%)
(progn (setq ,value (list (let* ,(remove nil
(list (when *compile-dependency-tracking?*
`(*notify-cons* (when *run-with-dependency-tracking?*
(list ,self-sym ',message-symbol))))
(when *compile-circular-reference-detection?*
`(*till-now* (when *run-with-circular-reference-detection?*
(cons (list ,self-sym ',message-symbol)
*till-now*))))))
,@body)
(when ,need? (list (copy-list *notify-cons*)))))
(if (not (eql (first ,value) 'gdl-rule:%not-handled%))
(setf (,message-symbol ,self-sym) ,value)
;;(without-interrupts (setf (,message-symbol ,self-sym) ,value))
(progn (setq ,need? nil)
(not-handled ,self-sym ',message-symbol))))
(when ,need? (add-notify-cons *notify-cons* ,value)))
(first ,value))))
#+nil
(defun add-notify-cons (notify-cons value)
(let ((matching-sublist (assoc (first notify-cons) (second value))))
(if matching-sublist (pushnew (second notify-cons) (rest matching-sublist))
(push (copy-list notify-cons) (second value)))))
;;
;; FLAG -- merge the following two back in when we have adaptive Abstract Associative Map.
;;
#+nil
(let ((value (gensym)) (need? (gensym)))
(defmacro with-dependency-tracking ((message-symbol &optional (self-sym 'self)) &rest body)
`(let ((,value (,message-symbol ,self-sym))
(,need? (and *run-with-dependency-tracking?*
*notify-cons* *root-checking-enabled?*)))
,(when *compile-circular-reference-detection?*
`(when (and *run-with-circular-reference-detection?*
(member (list ,self-sym ',message-symbol) *till-now* :test #'equalp))
(error "Circular reference detected")))
,(when *compile-with-dependency-recording?*
`(when (and ,*run-with-dependency-recording?*
*notify-cons*)
(let ((current-hash (gethash (first *notify-cons*) *dependency-hash*)))
(unless current-hash
(setf (gethash (first *notify-cons*) *dependency-hash*)
(make-hash-table)))
(pushnew (list ,self-sym ,(make-keyword message-symbol))
(gethash (make-keyword (second *notify-cons*))
(gethash (first *notify-cons*) *dependency-hash*))
:test #'equalp))))
(when (eq (first (ensure-list ,value)) 'gdl-rule::%unbound%)
(progn (setq ,value (list (let* ,(remove nil
(list (when *compile-dependency-tracking?*
`(*notify-cons* (when *run-with-dependency-tracking?*
(list ,self-sym ',message-symbol))))
(when *compile-circular-reference-detection?*
`(*till-now* (when *run-with-circular-reference-detection?*
(cons (list ,self-sym ',message-symbol)
*till-now*))))))
,@body)
nil))
(if (not (eql (first ,value) 'gdl-rule:%not-handled%))
(setf (,message-symbol ,self-sym) ,value)
(progn (setq ,need? nil)
(not-handled ,self-sym ',message-symbol)))))
(when ,need? (add-notify-key *notify-cons* ,value))
(first ,value))))
#+nil
(defun add-notify-key (notify-cons value)
(if (second value)
(pushnew (second notify-cons) (gethash (first notify-cons) (second value)))
(setf (second value)
(let ((ht (make-hash-table)))
(setf (gethash (first notify-cons) ht) (list (second notify-cons)))
ht))))
#+nil
(defun same-tree? (obj1 obj2) (eql (gdl-acc::%root% obj1) (gdl-acc::%root% obj2)))
(defun same-tree? (obj1 obj2)
(or (eql (gdl-acc::%root% obj1) (gdl-acc::%root% obj2))
(let ((root-1 (gdl-acc::%root% obj1)) (root-2 (gdl-acc::%root% obj2)))
(let ((god-parents-1 (gdl-acc::%god-parents% root-1))
(god-parents-2 (gdl-acc::%god-parents% root-2)))
(member root-1 god-parents-2) (member root-2 god-parents-1)))))
(defun add-godparent (target new)
(pushnew new (gdl-acc::%god-parents% target)))
(defun merge-common-keys (plist)
;; FLAG - call recursively until no more non-standard keywords remain.
(setq plist (expand-define-object-macros-toplevel plist))
(let ((ht (make-hash-table)) result)
(mapc #'(lambda(key value) (let ((current (gethash key ht)))
;; FLAG consider nconc here.
(setf (gethash key ht) (if current (append current value) value))))
(plist-keys plist) (plist-values plist))
(maphash #'(lambda(key value) (push key result) (push value result)) ht) (nreverse result)))
(defun expand-define-object-macros-toplevel (plist)
(let (standards expansions)
(mapc #'(lambda(keyword contents)
(if (member keyword *allowed-define-object-toplevel-keywords*)
(let ((current (list keyword contents)))
(if standards (nconc standards current) (setq standards current)))
(let ((expansion (expand-object-macro-toplevel keyword contents)))
(if expansions (nconc expansions expansion) (setq expansions expansion)))))
(plist-keys plist)(plist-values plist))
(append standards expansions)))
(defmacro define-object-macro-toplevel (keyword (specs) &body body)
`(defmethod expand-object-macro-toplevel ((keyword (eql ,keyword)) ,specs)
,@body))
(defgeneric expand-object-macro-toplevel (keyword specs))
(defmethod expand-object-macro-toplevel ((keyword t) specs)
(declare (ignore specs))
(error "~&~%~%No such toplevel define-object keyword exists as ~s.~%~%" keyword))
(defclass gdl-basis () () (:metaclass gdl-class))
(defclass gdl-remote () () (:metaclass gdl-class))
(defun to-double-float (num) (coerce num 'double-float))
(defun to-single-float (num) (coerce num 'single-float))
(defvar *patch-fasls* nil)
(defun load-quicklisp (&key (path *quicklisp-home*))
"Void. This is intended for pre-built Gendl or GDL images. If the
preconfigured quicklisp load file exists, load it. You can customize
quicklisp location by setting global *quicklisp-home* or passing :path
keyword argument to this function.
:&key ((path *quicklisp-home*) \"Pathname or string. Quicklisp location.\")
"
(let ((ql-loader (or (probe-file (merge-pathnames "program/load-ql.lisp" glisp:*gendl-home*)) ;; linux, windows prebuilt image
(probe-file (merge-pathnames "load-ql.lisp" glisp:*gendl-home*)) ;; Mac prebuilt image
(probe-file (merge-pathnames "../load-ql.lisp" *quicklisp-home*))))) ;; loading from source
(if (and ql-loader (probe-file ql-loader))
(let ((*quicklisp-home* path)) (load ql-loader))
(warn "load-ql.lisp was not found in ~a.~%" ql-loader))))
(defun load-glime ()
"Void. If the Glime (Slime Gendl auto-completion extensions) file exists, load it.
Path is currently hardcoded to <tt>(merge-pathnames \"emacs/glime.lisp\" glime:*gdl-home*)</tt>
or <tt>~/genworks/gendl/emacs/glime.lisp</tt>.
"
(let ((glime-source (or (probe-file (merge-pathnames "emacs/glime.lisp" glisp:*gendl-home*))
(probe-file (merge-pathnames "genworks/gendl/emacs/glime.lisp" (user-homedir-pathname))))))
(if (probe-file glime-source)
(load (compile-file glime-source :output-file (make-pathname :defaults (glisp:temporary-file) :type glisp:*fasl-extension*)))
(warn "Glime source not found at ~s.~%" glime-source))))
(defun keywordize-plist (plist)
(mapcan #'(lambda (key val)
(list (make-keyword key)
(if (atom val) val (keywordize-plist val))))
(plist-keys plist) (plist-values plist)))
(defun one-line (string)
(glisp:replace-regexp (glisp:replace-regexp string (format nil "~%") " ") "'" "\\'" ))
(defun inverted-readtable ()
(let ((readtable (copy-readtable)))
(setf (readtable-case readtable) :invert)
readtable))
| 18,646 | Common Lisp | .lisp | 368 | 43.252717 | 128 | 0.646622 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | d2045f698f833d768c14750c11cdbcbc23ceef497518c73516990b3127ad5780 | 36,073 | [
-1
] |
36,074 | metaclasses.lisp | lisp-mirror_gendl/base/source/metaclasses.lisp | ;;
;; Copyright 2002-2011 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)
(defclass gdl-class (standard-class)
((messages :accessor messages :initform nil)
(gdl-documentation :accessor gdl-documentation :initform nil)
(required-input-slots :accessor required-input-slots :initform nil)
(optional-input-slots :accessor optional-input-slots :initform nil)
(defaulted-input-slots :accessor defaulted-input-slots :initform nil)
(computed-slots :accessor computed-slots :initform nil)
(query-slots :accessor query-slots :initform nil)
(settable-computed-slots :accessor settable-computed-slots :initform nil)
(uncached-computed-slots :accessor uncached-computed-slots :initform nil)
(settable-optional-input-slots :accessor settable-optional-input-slots :initform nil)
(settable-defaulted-input-slots :accessor settable-defaulted-input-slots :initform nil)
(functions :accessor functions :initform nil)
(methods :accessor methods :initform nil)
(cached-functions :accessor cached-functions :initform nil)
(cached-methods :accessor cached-methods :initform nil)
(objects :accessor objects :initform nil)
(quantified-objects :accessor quantified-objects :initform nil)
(hidden-objects :accessor hidden-objects :initform nil)
(quantified-hidden-objects :accessor quantified-hidden-objects :initform nil)
(trickle-down-slots :accessor trickle-down-slots :initform nil)
(trickle-down-effective :accessor trickle-down-effective :initform nil)
(settable-slots :accessor settable-slots :initform nil)
(message-documentation :accessor message-documentation :initform nil)
(message-source :accessor message-source :initform nil)
(message-source-copy :accessor message-source-copy :initform nil)
(message-source-changed :accessor message-source-changed :initform nil)
(format-functions :accessor format-functions :initform nil)
(child-inputs :accessor child-inputs :initform nil)
))
(defclass gdl-format-class (standard-class)
((gdl-documentation :accessor gdl-documentation :initform nil)
(format-functions :accessor format-functions :initform nil)
(output-functions :accessor output-functions :initform (make-hash-table))
(view-documentation :accessor view-documentation :initform (make-hash-table))))
(defclass gdl-skin-class (standard-class) ())
(defmethod glisp:validate-superclass ((class gdl-class) (superclass standard-class)) t)
(defmethod glisp:validate-superclass ((class gdl-format-class) (superclass standard-class)) t)
(defmethod glisp:validate-superclass ((class gdl-skin-class) (superclass standard-class)) t)
| 3,420 | Common Lisp | .lisp | 60 | 53.883333 | 95 | 0.778944 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | f0ebfe036cf89d13a43944511a78b6b7efd408f051791bde69044d4abf8d8531 | 36,074 | [
-1
] |
36,075 | genworks.lisp | lisp-mirror_gendl/base/source/genworks.lisp | ;;;; -*- coding: utf-8 -*-
;;
;; Copyright 2002-2011, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; 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 :com.genworks.lisp)
(defparameter *external-text-format* :default)
(defparameter *fasl-extension*
#+allegro excl:*fasl-default-type*
#+lispworks compiler:*fasl-extension-string*
#+sbcl sb-fasl:*fasl-file-type*
#+ccl (pathname-type ccl:*.fasl-pathname*)
#+abcl "abcl"
#+clisp "fas"
#-(or allegro lispworks sbcl ccl abcl clisp) (error "Need fasl extension string for the currently running lisp.~%"))
#+nil
(defparameter *external-text-format*
#+(and mswindows allegro) (excl:crlf-base-ef :1252)
#-(and mswindows allegro) :default)
(defparameter *genworks-source-home* nil)
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun set-genworks-source-home-if-known ()
(when (find-package :asdf)
(multiple-value-bind (base-home error)
(ignore-errors (funcall (read-from-string "asdf:system-source-directory") "base"))
(if (typep error 'error)
(warn "~&ASDF is loaded, but :base is not registered. glisp:*genworks-source-home* remains unknown and set to nil.~%")
(when base-home
(setq *genworks-source-home*
(make-pathname :name nil
:type nil
:directory (butlast (butlast (pathname-directory base-home)))
:defaults base-home)))))))
;;(set-genworks-source-home-if-known)
)
(defparameter *gendl-source-home* nil)
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun set-gendl-source-home-if-known ()
(when (find-package :asdf)
(multiple-value-bind (gendl-home error)
(ignore-errors (funcall (read-from-string "asdf:system-source-directory") "gendl"))
(if (typep error 'error)
(warn "~&ASDF is loaded, but :base is not registered. glisp:*genworks-source-home* remains unknown and set to nil.~%")
(setq *gendl-source-home* gendl-home)))))
;;(set-gendl-source-home-if-known)
)
#-(or allegro lispworks sbcl ccl abcl ecl clisp)
(error "Need implementation for command-line-arguments in currently running lisp.~%")
(defun basic-command-line-arguments ()
#+allegro (sys:command-line-arguments :application nil)
#+lispworks system:*line-arguments-list*
#+sbcl sb-ext:*posix-argv*
#+ccl (ccl::command-line-arguments)
#+abcl extensions:*command-line-argument-list*
#+ecl (loop for n from 0 below (si:argc) collect (si:argv n))
#+clisp (coerce (ext:argv) 'list)
)
#-(or allegro lispworks cmu sbcl ccl abcl ecl clisp)
(error "Need implementation for executable-homedir-pathname for currently running lisp.~%")
(defun executable-homedir-pathname ()
#+allegro (translate-logical-pathname "sys:")
#+sbcl (make-pathname :name nil :type nil :defaults sb-ext:*core-pathname*)
#+(or lispworks ccl ecl clisp)
(let* ((exe (first (glisp:basic-command-line-arguments)))
(exe-dir (pathname-directory exe)))
(if (eql (first exe-dir) :relative) (uiop/os:getcwd)
(make-pathname :name nil :type nil :defaults exe)))
#+abcl
(warn "Don't know how to get executable-homedir-pathname on ~a! Please find out.~%"
(lisp-implementation-type)))
(defparameter *gdl-program-home* #-abcl (glisp:executable-homedir-pathname)
#+abcl
(progn (warn "Don't know how to get executable-homedir-pathname on ~a! Please find out.~%"
(lisp-implementation-type)) nil))
(defparameter *gendl-program-home* *gdl-program-home*)
(defparameter *gdl-home* #-abcl
(make-pathname :name nil
:type nil
:directory (butlast (pathname-directory *gdl-program-home*))
:defaults *gdl-program-home*)
#+abcl
(progn (warn "Don't know how to get *gdl-home* on ABCL! Please find out.~%")
nil))
(defparameter *gendl-home* *gdl-home*)
;;
;; FLAG -- bind these redefinitions more precisely/surgically. for
;; now we are using a sledgehammer and just turning off
;; redefinition warnings until we get a better handle on
;; things.
;;
#-(or allegro lispworks sbcl clisp)
(warn "Need parameter for redefinition warnings for currently running lisp.~%")
(let (#+(or allegro lispworks clisp)
(original-redefinition-warnings
#+allegro excl:*redefinition-warnings*
#+lispworks lw:*redefinition-action*
#+clisp custom:*suppress-check-redefinition*))
(defun begin-redefinitions-ok ()
#+sbcl (declare (sb-ext:muffle-conditions sb-ext:compiler-note))
#+(or allegro lispworks clisp)
(setq #+allegro excl:*redefinition-warnings*
#+lispworks lw:*redefinition-action*
#+clisp custom:*suppress-check-redefinition* nil))
(defun end-redefinitions-ok ()
#+sbcl (declare (sb-ext:unmuffle-conditions sb-ext:compiler-note))
#+(or allegro lispworks clisp)
(setq #+allegro excl:*redefinition-warnings*
#+lispworks lw:*redefinition-action*
#+clisp custom:*suppress-check-redefinition*
original-redefinition-warnings)))
#-(or allegro lispworks cmu sbcl ccl abcl ecl clisp)
(error "Need implementation for current-directory for currently running lisp.~%")
(defun current-directory ()
#+allegro (excl:current-directory)
#+lispworks (sys:current-directory)
#+(or sbcl abcl ecl clisp) *default-pathname-defaults*
#+cmu (second (multiple-value-list (unix:unix-current-directory)))
#+ccl (ccl:current-directory)
)
;;
;; From SBCL manual (to avoid redef errors when compiling/loading defconstants in SBCL):
;;
(defmacro define-constant (name value &optional doc)
`(defconstant ,name (if (boundp ',name) (symbol-value ',name) ,value)
,@(when doc (list doc))))
#-(or allegro lispworks sbcl ccl abcl ecl clisp)
(error "Need implementation for class-direct-superclasses for currently running lisp.~%")
(defun direct-superclasses (class)
"Return a list of the direct superclasses."
(#+(or allegro abcl) mop:class-direct-superclasses
#+lispworks hcl:class-direct-superclasses
#+sbcl sb-mop:class-direct-superclasses
#+ccl ccl:class-direct-superclasses
#+(or ecl clisp) clos:class-direct-superclasses class))
(defun direct-superclass-names (class)
"Return a list of names of the direct superclasses."
(mapcar #'gl-class-name
(direct-superclasses class)))
#-(or allegro lispworks cmu sbcl ccl abcl ecl clisp)
(error "Need implementation for eql-specializer for currently running lisp.~%")
(defun eql-specializer (attr-sym)
#+(or allegro abcl) (mop:intern-eql-specializer attr-sym)
#+(or lispworks cmu) (list 'eql attr-sym)
#+sbcl (sb-mop:intern-eql-specializer attr-sym)
#+ccl (ccl:intern-eql-specializer attr-sym)
#+(or ecl clisp) (clos:intern-eql-specializer attr-sym)
)
(defun ensure-string (string-designator)
(string string-designator))
(defun find-feature (feature) (find feature *features*))
#-(or allegro lispworks sbcl ccl abcl ecl clisp)
(error "Need implementation of featurep for currently running lisp.~%")
;;
;; FLAG -- for full-featured featurep, use uiop:featurep
;;
(defun featurep (x) (find x *features*))
(defun find-feature-version (feature &optional (errorp t))
(when (find-package :asdf)
(let ((system (funcall (read-from-string "asdf:find-system")
(intern feature :keyword) errorp)))
(when system (funcall (read-from-string "asdf:component-version") system)))))
(defun gl-class-name (class)
"Return the class name."
(#-cmu class-name #+cmu mop:class-name class))
#-(or allegro lispworks cmu sbcl ccl abcl ecl clisp)
(error "Need implementation for method-specializers for currently running lisp.~%")
(defun gl-method-specializers (method)
"Return a list of method specializers for the given method."
(#+(or allegro abcl) mop:method-specializers
#+lispworks hcl:method-specializers
#+cmu pcl:method-specializers
#+sbcl sb-mop:method-specializers
#+ccl ccl:method-specializers
#+(or ecl clisp) clos:method-specializers
method))
(defun hex-string-to-integer (string)
#+allegro(excl:hex-string-to-integer string)
#-allegro
(let ((*read-base* 16) *read-eval*) (read-from-string string)))
;;
;; FLAG -- where ever this is used, we can pass it a raw symbol now -
;; no more need to do (symbol-name ...) or (string ...) around the argument
;; to this.
;;
(defun intern (symbol &optional (package *package*))
(common-lisp:intern (string symbol) package))
#-allegro(warn "Find implementation for make-sans-value-equalp-hash-table for currently running lisp.~%")
(defun make-sans-value-equalp-hash-table ()
"Make an equalp hash-table that acts like a set - just keys, no values."
#+allegro (make-hash-table :values nil :test #'equalp)
#-allegro (make-hash-table :test #'equalp))
#-allegro(warn "Find implementation for make-sans-value-hash-table for currently running lisp.~%")
(defun make-sans-value-hash-table (&key (size nil))
"Make a hash-table that acts like a set - just keys, no values."
(if size
#+allegro (make-hash-table :values nil :size size)
#-allegro (make-hash-table :size size)
#+allegro (make-hash-table :values nil)
#-allegro (make-hash-table)))
(defun make-versioned-features (feature)
(mapcar #'(lambda(string)
(intern string :keyword))
(remove
nil
(list feature (let ((version (find-feature-version feature nil)))
(when version (format nil "~a-~a" feature version)))))))
;;
;; FLAG -- add missing options e.g. :key-or-value for LW.
;;
#-(or allegro lispworks sbcl ccl abcl ecl clisp)
(error "Need implementation for make-weak-hash-table for currently running lisp.~%")
#+ecl (warn "Need weak-hash-tables for ECL, or we will be running out of memory in web apps.~%")
(defun make-weak-hash-table (&rest args &key (weakness :key-and-value) &allow-other-keys)
(flet ((remove-plist-key (plist key)
(let (result on-remark?)
(dolist (element plist (nreverse result))
(cond ((eql element key)
(setq on-remark? t))
(on-remark?
(setq on-remark? nil))
(t (push element result)))))))
(apply #'make-hash-table
#+allegro :weak-keys #+allegro (case weakness ((:key-and-value :key) t) (otherwise nil))
#+allegro :values #+allegro (case weakness
((:key-and-value :value) :weak)
(otherwise (let ((values (getf args :values :missing)))
(ecase values
(:missing t)
(:weak :weak)
('nil nil)))))
#+lispworks :weak-kind #+lispworks (ecase weakness
(:key-and-value :both)
(:key :key) (:value :value))
#+(or sbcl abcl) :weakness #+(or sbcl abcl) (ecase weakness
(:key-and-value :key-and-value)
(:key :key) (:value :value))
#+clisp :weak #+clisp (ecase weakness
(:key-and-value :key-and-value)
(:key :key) (:value :value))
#+ccl :weak #+ccl (ecase weakness (:key-and-value :key) (:key :key) (:value :value)) #+ccl :test #+ccl (case weakness ((:key-and-value :key) #'eq) (otherwise #'eql))
(remove-plist-key args :weakness))))
#-(or allegro lispworks sbcl ccl clisp abcl)
(error "Need implementation for package-documentation for the currently running Lisp.~%")
(defun package-documentation (package)
#+(or allegro lispworks ccl clisp) (documentation (find-package package) t)
#+sbcl (sb-kernel:package-doc-string (find-package package))
#+abcl (format nil "Please find how to get documentation for ~a" (find-package package))
)
(defun set-default-character-width ()
#+lispworks (lispworks:set-default-character-element-type 'lispworks:simple-char)
)
(defun set-default-float-format ()
#+allegro (tpl:setq-default *read-default-float-format* 'double-float)
#+ccl (ccl::def-standard-initial-binding *read-default-float-format* 'double-float)
(setq *read-default-float-format* 'double-float))
(defun set-default-package ()
#+allegro (tpl:setq-default *package* (find-package :gdl-user))
(setq *package* (find-package :gdl-user))
#+allegro
(rplacd (assoc 'tpl::*saved-package*
tpl:*default-lisp-listener-bindings*) (find-package :gdl-user))
#+allegro (top-level:do-command "package" :gdl-user))
(defun set-defpackage-behavior ()
#+lispworks (setq hcl:*handle-existing-defpackage* (list :add))
#-lispworks nil ;; No action needed for non-lispworks platform currently.
)
(defun set-settings (settings)
(let (anything-changed?)
(dolist (setting settings)
(destructuring-bind (symbol default new-value-or-func) setting
(let ((new-value (if (functionp new-value-or-func)
(funcall new-value-or-func) new-value-or-func)))
(unless (equalp (symbol-value symbol) new-value)
(setf (symbol-value symbol) new-value)
(setq anything-changed? t)
(format t "~&Set ~s from default value ~s to non-default value ~s.~%"
symbol default new-value))))) anything-changed?))
(defun set-features (features)
(let (anything-changed?)
(dolist (feature features)
(dolist (feature (make-versioned-features feature))
(unless (or (null feature) (glisp:featurep feature))
(format t "~&Pushing ~s onto *features*.~%" feature)
(push feature *features*)
(setq anything-changed? t)))) anything-changed?))
#-allegro(warn "Find out how to retitle relevant windows in currently running lisp.~%")
#+(and allegro mswindows)
(defun set-window-titles ()
(excl:console-control :title "Genworks Gendl® Console")
;;(retitle-emacs)
)
#-(and allegro mswindows)
(defun set-window-titles ())
#-(or allegro lispworks abcl clozure sbcl) (warn "Find out how to get the source-pathname in current lisp.")
(defun source-pathname ()
#+allegro excl:*source-pathname*
#+lispworks dspec:*source-pathname*
#+sbcl (or *compile-file-truename* *load-truename*)
#+ccl (translate-logical-pathname ccl:*loading-file-source-file*)
#+clisp (error "need source-pathname in clisp~%")
#+abcl (extensions:source-pathname)
)
#+nil
(defun retitle-emacs (&key (title "Genworks Gendl™ Interactive Authoring Environment"))
"Retitles the associated GDL emacs window with the specified title.
:arguments (title \"The title to be placed on emacs title bar.\")"
(declare (ignorable title))
#+allegro
(when (lep:lep-is-running)
(lep::eval-in-emacs "(defun frame-retitle (title)
(modify-frame-parameters nil (list (cons 'name title))))")
(lep::eval-in-emacs (concatenate 'string "(frame-retitle \"" title "\")"))))
(defun system-description (system-designator &optional (errorp t))
(let (description (home (system-home system-designator errorp)))
(when home
(let ((description-file (merge-pathnames "description.isc" home)))
(when (probe-file description-file)
(setq description
(with-open-file (in description-file :external-format #+lispworks :default #-lispworks :utf-8) (read in))))))
(or description (format nil "~a Subsystem" system-designator))))
(defun system-home (system-designator &optional (errorp t))
(if (find-package :asdf)
(funcall (read-from-string "asdf:system-source-directory") system-designator)
(when errorp (error "~&glisp:system-home was called, but cannot function because asdf is not loaded.~%"))))
(defun upcase (string)
"Upcases the string, except in Allegro-CL's case-sensitive-lower mode, in which case the string is not modified."
#-allegro (string-upcase string)
#+allegro (ecase excl:*current-case-mode*
(:case-insensitive-upper (string-upcase string))
(:case-sensitive-lower string)))
;;
;; FLAG w-o-interrupts is deprecated and ineffective in an SMP Lisp.
;; glisp:w-o-interrupts becomes a simple progn currently.
;; This must be replaced with e.g. appropriate process-locks.~%
;;
(defmacro w-o-interrupts (&body body)
`(progn ,@body))
(defmacro without-package-variance-warnings (&body body)
`(eval-when (:compile-toplevel :load-toplevel :execute)
(handler-bind (#+sbcl(sb-int:package-at-variance #'muffle-warning))
,@body)))
;;
;; FLAG -- fill these next two in with simple equivalent on each
;; lisp. Don't want to depend on libraries yet.
;;
(defmacro with-lock-held ((lock) &body body)
(declare (ignore lock))
`(progn ,@body))
(defun make-lock (name)
name)
| 16,803 | Common Lisp | .lisp | 365 | 42.131507 | 169 | 0.70745 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 4f1180b34dcce2e2fdc5dad379a3d75828ee4457747f4cddd119d934c5970b90 | 36,075 | [
-1
] |
36,076 | parameters.lisp | lisp-mirror_gendl/base/source/parameters.lisp | ;;
;; Copyright 2002-2011 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)
(defparameter *gendl-version* "1595")
(defparameter *gendl-patch-level* nil)
(eval-when (:compile-toplevel :load-toplevel :execute)
(when (not (boundp '*production-build?*)) (defvar *production-build?* nil)))
;;
;; FLAG this belongs in :geom-base.
;;
(defparameter *curve-chords* 50
"Integer. The number of chords to use per Bezier curve when rendering
curves as a sequence of straight chords (e.g. in VRML).")
(defparameter *compiling-changes* nil)
(defvar *load-source-code-database?* t ;;(not *production-build?*)
"Boolean. Determines whether pre-compiled source code
information will be loaded from compiled files. Defaults to T.")
(defvar *load-documentation-database?* t ;;t ;;(not *production-build?*)
"Boolean. Determines whether pre-compiled documentation strings
information will be loaded from compiled files. Defaults to T.")
(defvar *compile-source-code-database?* t ;;(not *production-build?*)
"Boolean. Determines whether source code information
information will be compiled into compiled files. Defaults to T.")
(defvar *compile-documentation-database?* t ;;t ;;(not *production-build?*)
"Boolean. Determines whether documentation strings
information will be compiled into compiled files. Defaults to T.")
(defparameter *retain-object-identity-on-type-change?* t)
(defparameter *dummy-version* (list 0))
(defparameter *notify-cons* nil)
(defparameter *root-checking-enabled?* t
"Boolean. Determines whether dependency-tracking carries over between objects which
do not share a common root. Default is T which means dependency-tracking does <b>not</b>
carry over (the checking prevents it).")
(defparameter *till-now* nil)
(defvar *compile-circular-reference-detection?* nil
"Boolean. This is a compile-time switch. Determines whether the system detects circular references
in messages. Defaults to NIL.")
(defvar *run-with-circular-reference-detection?* nil
"Boolean. This is a runtime switch. Determines whether the system detects circular references
in messages. Defaults to NIL.")
;;(defvar *compile-circular-reference-detection?* t)
;;(defvar *run-with-circular-reference-detection?* t)
(defvar *compile-dependency-tracking?* t
"Boolean. This is a compile-time switch. Determines whether the system keeps track of object and message
dependencies at runtime, thereby enabling the modification of messages and subsequent proper
demand-driven recomputation of other messages in the object hierarchy. This switch must
be set at the beginning of a session before comiling all code; switching it in the middle
of a session (especially from NIL to T) will have unpredictable effects and very likely will
result in incorrect operation. Defaults to T.")
(defvar *run-with-dependency-tracking?* t
"Boolean. This is a runtime switch. Determines whether the system keeps track of object and message
dependencies at runtime, thereby enabling the modification of messages and subsequent proper
demand-driven recomputation of other messages in the object hierarchy. This switch must
be set at the beginning of a session; switching it in the middle of a session (especially
from NIL to T) will have unpredictable effects and very likely will result in incorrect
operation. Defaults to T.")
(defvar *undeclared-parameters-enabled?* nil ;;t
"Boolean. This is a compile-time switch. Determines whether the system will handle inputs passed
to child parts through :parameters plists, where the input is not declared in any other
part as either an input-slot or computed-slot. If you leave this as NIL when compiling
your application you may see an improvement in runtime performance of up to 10% as
compared to applications compiled with it set to T. Defaults to NIL.")
(defparameter *debug?* nil)
(defparameter *debug-object* nil)
(defparameter *report-gdl-redefinitions?* t)
(defparameter *allowed-part-documentation-keywords*
(list :author :purpose :description :examples :example))
(defparameter *message-categories*
(list :required-input-slots :optional-input-slots :settable-optional-input-slots
:defaulted-input-slots :settable-defaulted-input-slots :computed-slots :settable-computed-slots
:uncached-computed-slots
:objects :quantified-objects :hidden-objects :quantified-hidden-objects
:functions :query-slots))
(defparameter *allowed-define-object-toplevel-keywords*
(list :input-slots :computed-slots :objects :hidden-objects :functions
:methods :trickle-down-slots :cached-functions :cached-methods
:documentation :no-vanilla-mixin? :query-slots))
(defparameter *define-object-toplevel-macros* (make-hash-table))
(defparameter *stream* nil)
(defparameter *colors-default* (list :foreground :black :background :white)
"Plist. Should contain keys of at least <tt>:foreground</tt> and <tt>:background</tt>, whose
values are a color indicator for the default foreground and background of graphics viewports. The
default is <tt>:black</tt> for foreground, and <tt>:white</tt> for background.")
(defparameter *%format%* nil)
;;(defvar args-arg (gensym))
;;(defvar parent-arg (gensym))
;;(defvar part-arg (gensym))
;;(defvar val-arg (gensym))
;;(defvar self-arg (gensym))
(defvar args-arg '+args-arg+)
(defvar parent-arg '+parent-arg+)
(defvar part-arg '+part-arg+)
(defvar val-arg '+val-arg+)
(defvar self-arg '+self-arg+)
(defparameter *error-on-not-handled?* t)
(glisp:define-constant +reserved-words+
(mapcar #'(lambda(symbol)
(glisp:intern symbol :gdl-acc))
'(aggregate
children
;;documentation
first
first?
follow-root-path
hidden-children
index
last
last?
leaf?
message-list
mixins
next
parent
parent-tree
previous
restore-slot-default!
root
root-path
root?
set-slot!
set-slots!
slot-documentation
type
update!
color-decimal
edge-center
face-center
face-normal-vector
local-center
obliqueness
vertex)))
(defparameter *error-on-reserved-words?* t)
(defparameter *compile-for-dgdl?* nil "Boolean. Determines whether
global methods are defined during compilation to allow calling any
message on a gdl remote-object. This functionality is not available
in the base by itself, it requires the :gwl system as well.
Defaults to nil.")
(defparameter *gs-path* nil)
(defparameter *sort-children?* nil
"Boolean. Determine whether to sort child objects in lexigraphical
order. Defaults to nil, which is the behavior previous to gdl1585.")
(defparameter *already-loaded-systems* nil)
(defparameter *packages-to-lock* (list :gendl :geom-base :cl-lite :gwl :gwl-graphics
:tasty :robot :tree :yadd :surf :smlib :genworks-gdl))
(defvar *quicklisp-home* nil)
| 7,991 | Common Lisp | .lisp | 163 | 43.840491 | 107 | 0.729754 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 290a3d4a8b9bff95283d62a309a447f44e65c3697905a0f6081f33262759679a | 36,076 | [
-1
] |
36,077 | start.lisp | lisp-mirror_gendl/base/source/start.lisp | ;;;; -*- coding: utf-8 -*- ;
;;
;; Copyright 2002-2011 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)
(defparameter *features-to-initialize* (list :base :glisp :geom-base :gwl
:gwl-graphics :tasty :yadd :robot :cl-lite :geysr))
(defun start-gendl! (&key (features *features-to-initialize*)
(banner? t) (init-files? t))
(glisp::set-gendl-source-home-if-known)
(glisp::set-genworks-source-home-if-known)
(dolist (feature features)
;;
;; This assumes feature name = package name of its initialize!
;; function. This is the case now. Let's hope we can keep it that
;; way.
;;
(let ((package feature))
(if (and (find-package package) (glisp:featurep feature))
(let ((function-sym (read-from-string (format nil "~a::initialize" package))))
(when (fboundp function-sym)
(let ((description (glisp:package-documentation package)))
(format t "~&Initializing ~a subsystem...~%" description)
(let ((anything-changed? (funcall function-sym)))
(format t "~&...Done~a~%"
(if anything-changed? "."
(format nil " (no new global settings).")))))))
(format t "~&Note: Feature ~s does not appear to be loaded at this time.~%" feature))))
(when banner? (startup-banner))
(when init-files? (load-gdl-init-files) )
(values))
(defun load-gdl-init-files ()
(let* ((user-homedir (user-homedir-pathname))
(current-directory (glisp:current-directory))
(homedir-init-file (or (probe-file (merge-pathnames ".gdlinit.cl" user-homedir))
(probe-file (merge-pathnames "gdlinit.cl" user-homedir))))
(current-init-file (when (not (equalp user-homedir current-directory))
(or (probe-file (merge-pathnames ".gdlinit.cl" current-directory))
(probe-file (merge-pathnames "gdlinit.cl" current-directory))))))
(let* ((command-args (glisp:basic-command-line-arguments))
(homedir-init? (and (not (member "-q" command-args :test #'string-equal))
(not (member "-qq" command-args :test #'string-equal))))
(current-dir-init? (not (member "-qq" command-args :test #'string-equal))))
(when (and current-dir-init? current-init-file) (load current-init-file))
(when (and homedir-init? homedir-init-file) (load homedir-init-file)))))
(defun quicklisp-copyright-string ()
(if *already-loaded-systems*
(let ((ql-libs
(safe-sort
(set-difference *already-loaded-systems*
(append (list "asdf" "crypt" "quicklisp" "base" "ent" "validate" "glisp"
"monofasl" "pro" "enterprise")
*packages-to-lock*)
:key #'string :test #'string-equal) #'string-lessp))
(ql-version (with-open-file (in (or (probe-file (merge-pathnames "dists/quicklisp/distinfo.txt" *quicklisp-home*))
(error "Quicklisp directory not found in gendl:*quicklisp-home*,
which is set to: ~a.~%" *quicklisp-home*)))
(read-line in) (string-trim (list #\space) (second (glisp:split-regexp ":" (read-line in)))))))
(format nil "Also contains the following Common Lisp libraries
from Quicklisp version ~a, whose source files are available in the
Quicklisp repository at http://quicklisp.org, Copyright© their
respective authors:
~%~%~{~a~^, ~}.~%" ql-version ql-libs)) ""))
(defun startup-banner ()
(format t
"
Gendl® Free Edition, version ~a
Within ~a ~a
~a
Welcome to Gendl®
Copyright© 2017, Genworks® International, Birmingham MI, USA.
All Rights Reserved.
This program 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 program 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 the source code for this program. If not, see:
http://www.gnu.org/licenses/
"
gendl:*gendl-version*
(lisp-implementation-type)
(lisp-implementation-version)
(quicklisp-copyright-string)
))
| 5,127 | Common Lisp | .lisp | 106 | 43.377358 | 119 | 0.688564 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 7861ace24c30ea1861e454b19c93ff95ad4d59c315b465ed3c8fb163962db3ee | 36,077 | [
-1
] |
36,078 | coordinate-system.lisp | lisp-mirror_gendl/documentation/tutorial/examples/coordinate-system.lisp | (in-package :gdl-user)
;;
;; FLAG -- this will be more useful as a view-scale-independent mixin
(define-object visible-coordinate-system (base-coordinate-system)
:input-slots ((length 10) (width 10) (height 10)
(show-axes? t :settable)
(show-face-labels? t :settable)
(grid-size 10)
(grid-pitch (/ (the length) (the grid-size))))
:objects
((box :type 'box
:display-controls (list :color :orange :transparency 0.8))
(x-pointer :type 'axis-pointer
:hidden? (not (the show-axes?))
:label "X"
:display-controls (list :color :red)
:length (half (the length))
:orientation (alignment :front (the (face-normal-vector :right))))
(x-lines :type 'line
:sequence (:size (1+ (the grid-size)))
:midpoint (translate (the (face-center :front)) :rear (* (the grid-pitch)
(the-child index)))
:pseudo-inputs (midpoint)
:start (translate (the-child midpoint) :left (half (the length)))
:end (translate (the-child midpoint) :right (half (the length))))
(y-pointer :type 'axis-pointer
:hidden? (not (the show-axes?))
:label "Y"
:display-controls (list :color :green)
:length (half (the length))
:orientation (alignment :front (the (face-normal-vector :rear))))
(y-lines :type 'line
:sequence (:size (1+ (the grid-size)))
:midpoint (translate (the (face-center :left)) :right (* (the grid-pitch)
(the-child index)))
:pseudo-inputs (midpoint)
:start (translate (the-child midpoint) :front (half (the length)))
:end (translate (the-child midpoint) :rear (half (the length))))
(z-pointer :type 'axis-pointer
:hidden? (not (the show-axes?))
:label "Z"
:display-controls (list :color :blue)
:length (half (the length))
:orientation (alignment :front (the (face-normal-vector :top))))
(front-label :type 'general-note
:hidden? (not (the show-face-labels?))
:center (the (face-center :front))
:orientation (alignment :top (the (face-normal-vector :front)))
:character-size 3
:strings "Front")
(rear-label :type 'general-note
:hidden? (not (the show-face-labels?))
:center (the (face-center :rear))
:orientation (alignment :top (the (face-normal-vector :rear)))
:character-size 3
:strings "Rear")
(right-label :type 'general-note
:hidden? (not (the show-face-labels?))
:center (the (face-center :right))
:orientation (alignment :top (the (face-normal-vector :right))
:rear (the (face-normal-vector :top)))
:character-size 3
:strings "Right")
(left-label :type 'general-note
:hidden? (not (the show-face-labels?))
:center (the (face-center :left))
:orientation (alignment :top (the (face-normal-vector :left))
:rear (the (face-normal-vector :top)))
:character-size 3
:strings "Left")
(top-label :type 'general-note
:hidden? (not (the show-face-labels?))
:center (the (face-center :top))
:orientation (alignment :top (the (face-normal-vector :top)))
:character-size 3
:strings "Top")
(bottom-label :type 'general-note
:hidden? (not (the show-face-labels?))
:center (the (face-center :bottom))
:orientation (alignment :top (the (face-normal-vector :bottom)))
:character-size 3
:strings "Bottom")))
(define-object axis-pointer (cylinder)
:input-slots (label (radius (/ (the length) 25)))
:objects
((shaft :type 'cylinder
:radius (the radius)
:center (translate (the center) :front (half (the length))))
(tip :type 'cone
:radius (the radius)
:center (translate (the shaft center) :front (+ (half (the length))
(half (the-child length))))
:orientation (alignment :rear (the (face-normal-vector :front)))
:length (/ (the length) 10))
#+nil
(note :type 'general-note
:display-controls (list :billboard t)
:center (translate (the tip center) :front (the-child character-size))
:strings (the label))))
| 4,050 | Common Lisp | .lisp | 99 | 34.979798 | 78 | 0.642308 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | cca8a5ba325cad2ee08fa39c3b9ae03f281c590fd35634263c25f25790f11c5b | 36,078 | [
-1
] |
36,079 | sequence-matrix.lisp | lisp-mirror_gendl/documentation/tutorial/examples/sequence-matrix.lisp | (in-package :gdl-user)
(define-object cyl-fields (base-object)
:input-slots ((number-of-layers 3)
(height 20)
(datum (the (face-center :bottom)))
(pitch (/ (the height) (1- (the number-of-layers))))
(colors (list :red :orange :yellow :green :blue :indigo :violet)))
:objects ((fields :type 'cyl-field
:display-controls (list :color (cyclic-nth (the-child index) (the colors)))
:sequence (:size (the number-of-layers))
:center (translate (the datum) :up (* (the-child index) (the pitch))))))
(define-object cyl-field (base-object)
:input-slots ((number-of-rows 10)
(number-of-columns (floor (* (the number-of-rows) +phi+)))
(cylinder-radius 2) (cylinder-length 3)
(width (twice (* (the cylinder-radius) (the number-of-rows))))
(length (twice (* (the cylinder-radius) (the number-of-columns))))
)
:objects
((cylinders :type 'cylinder
:sequence (:matrix :lateral (the number-of-rows) :longitudinal (the number-of-columns))
:radius (the cylinder-radius)
:length (the cylinder-length)
:orientation (alignment :rear (the (face-normal-vector :top)))
)))
(define-object cyl-centered (base-object)
:input-slots ((number-of-rows 10)
(number-of-columns (floor (* (the number-of-rows) +phi+)))
(cylinder-radius 2) (cylinder-length 3)
(width (twice (* (the cylinder-radius) (the number-of-rows))))
(length (twice (* (the cylinder-radius) (the number-of-columns))))
)
:objects
((cylinders :type 'cylinder
:sequence (:matrix :lateral (the number-of-rows) :longitudinal (the number-of-columns))
:radius (the cylinder-radius)
:length (the cylinder-length)
:center (translate (the center)
:left (* (first (the-child index)) (* 7/4 (twice (the-child radius))))
:rear (* (second (the-child index)) (* 8/3 (twice (the-child radius)))))
:orientation (alignment :rear (the (face-normal-vector :top)))
)))
| 1,962 | Common Lisp | .lisp | 42 | 41.428571 | 94 | 0.657672 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a733f3d2c9e3369bb088da8349234367acec4ba8311781c6cf6ae6530875453b | 36,079 | [
-1
] |
36,080 | styles.lisp | lisp-mirror_gendl/documentation/tutorial/source/styles.lisp | (in-package :gendl-doc)
(defparameter *styles*
'(
(body
(font-family "\'Arial\'")
(margin-left "10%")
(margin-right "10%"))
(a
(color "#666")
(text-decoration "none"))
("a:hover"
(color "#ccc"))
(pre
(background-color "#eee")
(padding "10px")
(border-radius "5px")
(font-family "monospace"))
(tt
(background-color "#eee"))
(div>ol
(border-left "6px solid #eee")
(margin "20px"))
(li
(margin "3px"))
("li li"
(font-size "90%"))
(dl
(margin-left "35px"))
(dt
(font-weight "bold"))))
| 657 | Common Lisp | .lisp | 30 | 15.033333 | 36 | 0.483819 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 88e204705105f53a7cb0a7765af26a5d864f3401f1894c6fedbe5c28402ed5a4 | 36,080 | [
-1
] |
36,081 | basic-operation.lisp | lisp-mirror_gendl/documentation/tutorial/source/basic-operation.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 :gendl-doc)
(defparameter *basic-operation*
`((:chapter :title "Basic Operation of the GDL Environment")
"This chapter will lead you through all the basic steps of
operating a typical GDL-based development environment. We will not in
this section go into particular depth about the additional features of
the environment or language syntax --- this chapter is merely to
familiarize you with, and start you practicing with the nuts and bolts
of operating the environment with a keyboard."
((:section :title "What is Different about GDL?")
"GDL is a "
(:emph "dynamic")
" language environment with incremental compiling and in-memory
definitions. This means that as long as the system is running you
can "
(:emph "compile")
" new "
(:emph "definitions")
" of functions, objects, etc, and they will immediately become
available as part of the running system, and you can begin testing
them immediately, or update an existing set of objects to observe
their new behavior.
In many other programming language systems, to introduce a new
function or object, one has "
(:emph "to start the system from the beginning")
" and reload all the files in order to test new functionality.
In GDL, it is typical to keep the same development session up and
running for an entire day or longer, making it unnecessary to
repeatedly recompile and reload your definitions from scratch. Note,
however, that if you do shut down and restart the system for some
reason, then you will have to recompile and/or reload your
application's definitions in order to bring the system back into a
state where it can instantiate (or ``run'') your application.
While this can be done manually at the command-line, it is typically
done "
(:emph "automatically")
" in one of two ways:"
(:ol
(:li "Using commands placed into
the "
(:texttt "gdlinit.cl")
" initialization file, as described in Section "
(:ref "sec:customizingyourenvironment") ".")
(:li "Alternatively, you can compile and load definitions into
your session, then save the ``world'' in that state. That way it is
possible to start a new GDL ``world'' which already has all your
application's definitions loaded and ready for use, without having to
procedurally reload any files. You can then begin to make and test new
definitions (and re-definitions) starting from this new ``world.''
You can think of a saved ``world'' like pre-made cookie dough: no need
to add each ingredient one by one --- just start making cookies!")))
((:section :title "Startup, ``Hello, World!'' and Shutdown")
(:p
"The typical GDL environment consists of three programs:"
(:ol
(:li "Gnu Emacs (the editor);")
(:li "a Common Lisp engine with GDL system loaded or built into it (e.g. the "
(:texttt "gdl.exe")
" executable in your "
(:texttt "program/")
" directory); and")
(:li "(optionally) a web browser such as Firefox, Google
Chrome, Safari, Opera, or Internet Explorer"))
"Emacs runs as the main "
(:emph "process")
", and this in turn starts the CL engine with GDL as a "
(:emph "sub-process")
". The CL engine typically runs an embedded "
(:emph "webserver")
", enabling you to access your application through a standard web browser.")
(:p "As described in Chapter "
(:ref "chap:installation[gdlandgendl]")
", the typical way to start a pre-packaged GDL environment is with the "
(:texttt "run-gdl.bat")
" (Windows), or "
(:texttt "run-gdl")
" (MacOS, Linux) script files, or with the installed Start
program item (Windows) or application bundle (MacOS). Invoke this
script file from the Start menu (Windows), your computer's file
manager, or from a desktop shortcut if you have created one. Your
installation executable may also have created a Windows ``Start'' menu
item for Genworks GDL. You can of course also invoke "
(:texttt "run-gdl.bat")
" from the Windows ``cmd'' command-line, or from another command shell such as Cygwin."
(:footnote "Cygwin is also useful as a command-line tool on Windows
for interacting with a version control system like Subversion (svn)."))
((:image-figure :caption "Startup of Emacs with GDL"
:image-file "emacs-startup.png"
:width "6in" :height "4in"
:label "fig:emacs-startup"))
((:subsection :title "Startup")
" Startup of a typical GDL development session consists of
two fundamental steps: (1) starting the Emacs editing environment,
and (2) starting the actual GDL process as a ``sub-process'' or ``inferior'' process
within Emacs. The GDL process should automatically establish a network connection
back to Emacs, allowing you to interact directly with the GDL process from within Emacs."
((:list :style :enumerate)
(:item "Invoke the "
(:texttt "run-gdl.bat") ", " (:texttt "run-gdl.bat") "
startup script, or the provided executable from the Start
menu (windows) or application bundle (Mac).")
(:item "You should see an emacs window similar to that shown in Figure "
(:ref "fig:emacs-startup")
". (alternative colors are also possible).")
(:item "(MS Windows): Look for the Genworks GDL Console
window, or (Linux, Mac) use the Emacs ``Buffer'' menu to visit the
``*inferior-lisp*'' buffer. Note that the Genworks GDL Console
window might start as a minimized icon; click or double-click it to
un-minimize.")
(:item "Watch the Genworks GDL Console window for any
errors. Depending on your specific installation, it may take from a
few seconds to several minutes for the Genworks GDL Console (or
*inferior-lisp* buffer) to settle down and give you a "
(:texttt "gdl-user(): ")
" prompt. This window is where you will see most of your program's textual output, any
error messages, warnings, etc.")
(:item "In Emacs, type: "
(:texttt "C-x &")
" (or select Emacs menu item "
(:emph "Buffers" (:$) (:rightarrow) (:$) "*slime-repl...*")
") to visit the ``*slime-repl ...*'' buffer. The full name
of this buffer depends on the specific CL/GDL platform which you are
running. This buffer contains an interactive prompt, labeled "
(:texttt "gdl-user>")
", where you will enter most of your commands to interact with your running GDL session
for testing, debugging, etc. There is also a web-based graphical interactive environment called "
(:emph "tasty")
" which will be discussed in Chapter "
(:ref "chap:thetastydevelopmentenvironment") ".")
(:item "To ensure that the GDL command prompt is up and running, type: "
(:texttt "(+ 2 3)")
" and press [Enter].")
(:item "You should see the result "
(:texttt "5")
" echoed back to you below the prompt.")))
((:subsection :title "Developing and Testing a ``Hello World'' application")
" "
((:list :style :enumerate)
(:item "type C-x (Control-x) 2, or C-x 3, or use the ``Split
Screen'' option of the File menu to split the Emacs frame into two
``windows'' (``windows'' in Emacs are non-overlapping panels, or
rectangular areas within the main Emacs window).")
(:item "type C-x o several times to move from one window to
the other, or move the mouse cursor and click in each window. Notice
how the blinking insertion point moves from one window to the other.")
(:item "In the top (or left) window, type C-x C-f (or select Emacs menu item
``File" (:$) (:rightarrow) (:$) "Open File'') to get the ``Find file'' prompt in the
mini-buffer.")
(:item "Type C-a to move the point to the beginning of the mini-buffer line.")
(:item "Type C-k to delete from the point to the end of the mini-buffer.")
(:item "Type "
(:texttt (:textasciitilde) "/hello.gdl")
" and press [Enter]")
(:item "You are now editing a (presumably new) file of GDL
code, located in your HOME directory, called "
(:texttt "hello.gdl"))
(:item "Enter the text from Figure "
(:ref "fig:simpleobjectdefinition")
" into the "
(:texttt "hello.gdl")
" buffer. You do not have to match the line breaks and whitespace as shown in the example.
You can auto-indent each new line by pressing [TAB] after pressing [Enter] for the newline."
(:p (:emph "Protip:") "You can also try using "
(:texttt "C-j")
" instead of [Enter], which will automatically give a newline and auto-indent."))
((:boxed-figure :caption "Example of Simple Object Definition"
:label "fig:simpleobjectdefinition")
(:verbatim "
(in-package :gdl-user)
(define-object hello ()
:computed-slots
((greeting \"Hello, World!\")))
"))
(:item "type " (:texttt "C-x C-s") " (or choose Emacs menu item "
(:emph "File" (:$) (:rightarrow) (:$) "Save")
") to save the contents of the buffer (i.e. the window)
to the file in your HOME directory.")
(:item "type " (:texttt "C-c C-k") " (or choose Emacs menu item "
(:emph "SLIME" (:$) (:rightarrow) (:$) "Compilation" (:$) (:rightarrow) (:$) "Compile/Load File")
") to compile & load the code from this file.")
(:item "type " (:texttt "C-c o") " (or move and click the mouse) to switch to the bottom window.")
(:item "In the bottom window, type " (:texttt "C-x &") " (or choose Emacs menu item "
(:emph "Buffers" (:$) (:rightarrow) (:$) "*slime-repl...*")
") to get the "
(:texttt "*slime-repl ...*") " buffer, which should contain a "
(:texttt "gdl-user>")
" prompt. This is where you normally type interactive GDL commands.")
(:item "If necessary, type "
(:texttt "M " (:textgreater))
" (that is, hold down Meta (Alt), Shift, and the ``" (:textgreater) "'' key) to
move the insertion point to the end of this buffer.")
(:item "At the "
(:texttt "gdl-user>")
" prompt, type "
(:verbatim "(make-self 'hello)")
" and press [Enter].")
(:item "At the "
(:texttt "gdl-user>")
" prompt, type "
(:verbatim "(the greeting)")
" and press [Enter].")
(:item "You should see the words "
(:texttt "Hello, World!")
" echoed back to you below the prompt.")
))
((:subsection :title "Shutdown")
" To shut down a development session gracefully, you should first shut down the GDL process,
then shut down your Emacs."
((:list :style :itemize)
(:item "Type "
(:texttt "M-x quit-gdl")
" (that is, hold Alt and press X, then release both while you type "
(:texttt "quit-gdl")
" in the mini-buffer), then press [Enter]")
(:item "alternatively, you can type "
(:texttt "C-x &")
" (that is, hold Control and press X, then release both while you type &.
This will visit the *slime-repl* buffer. Now type: "
(:texttt ", q")
" to quit the GDL session.")
(:item "Finally, type "
(:texttt "C-x C-c")
" to quit from Emacs. Emacs will prompt you to save any
modified buffers before exiting."))))
((:section :title "Working with Projects")
"GDL contains utilities which allow you to treat your
application as a ``project,'' with the ability to compile,
incrementally compile, and load a ``project'' from a directory tree of
source files representing your project. In this section we provide an
overview of the expected directory structure and available control
files, followed by a reference for each of the functions included in
the bootstrap module."
((:subsection :title "Directory Structure")
(:p "You should structure your applications in a modular
fashion, with the directories containing actual Lisp sources called
\"source.\" You may have subdirectories which themselves contain
\"source\" directories. We recommend keeping your codebase directories
relatively flat, however.")
(:p "In Figure "
(:ref "fig:yoyodyne-base")
" is an example application directory, with four source files.")
((:boxed-figure :caption "Example project directory with four source files"
:label "fig:yoyodyne-base")
(:verbatim "
apps/yoyodyne/booster-rocket/source/assembly.gdl
apps/yoyodyne/booster-rocket/source/package.gdl
apps/yoyodyne/booster-rocket/source/parameters.gdl
apps/yoyodyne/booster-rocket/source/rules.gdl
")))
((:subsection :title "Source Files within a source/ subdirectory")
((:subsubsection :title "Enforcing Ordering")
(:p "Within a source subdirectory, you may have a file called "
(:texttt "file-ordering.isc")
(:footnote (:texttt "isc") " stands for ``Intelligent Source Configuration''")
" to enforce a certain ordering of the files. Here are
the contents of an example for the above application:")
(:verbatim "(\"package\" \"parameters\")")
(:p "This will force package.lisp to be compiled/loaded first, and
parameters.lisp to be compiled/loaded next. The ordering on the rest
of the files should not matter (although it will default to
lexigraphical ordering).")
(:p "Now our sample application directory appears as in
Figure "
(:ref "fig:yoyodyne-with-file-ordering-isc")
"."))
((:boxed-figure :caption "Example project directory with file ordering configuration file"
:label "fig:yoyodyne-with-file-ordering-isc")
(:verbatim "
apps/yoyodyne/booster-rocket/source/assembly.gdl
apps/yoyodyne/booster-rocket/source/file-ordering.isc
apps/yoyodyne/booster-rocket/source/package.gdl
apps/yoyodyne/booster-rocket/source/parameters.gdl
apps/yoyodyne/booster-rocket/source/rules.gdl"))
)
((:subsection :title "Generating an ASDF System")
(:p "ASDF stands for Another System Definition Facility, which
is the predominant system in use for Common Lisp third-party
libraries. With GDL, you can use the "
(:texttt ":create-asd-file?")
" keyword argument to make cl-lite generate an ASDF system
file instead of actually compiling and loading the system. For example: "
(:verbatim "(cl-lite \"apps/yoyodyne/\" :create-asd-file? t)"))
(:p "In order to include a depends-on clause in your ASDF system file, create a file called "
(:texttt "depends-on.isc")
" in the toplevel directory of your system. In this file,
place a list of the systems your system depends on. This can be
systems from your own local projects, or from third-party libraries.
For example, if your system depends on the "
(:texttt ":cl-json")
" third-party library, you would have the following contents in your "
(:texttt "depends-on.isc")
": "
(:verbatim "(:cl-json)")))
((:subsection :title "Compiling and Loading a System")
"Once you have generated an ASDF file, you can compile and
load the system using Quicklisp. To do this for our example, follow these steps:"
((:list :style :enumerate)
(:item (:verbatim "(cl-lite \"apps/yoyodyne/\" :create-asd-file? t)")
" to generate the asdf file for the yoyodyne system. This only has to be done once after every time you add, remove, or rename a file or folder from the system.")
(:item (:verbatim "(pushnew \"apps/yoyodyne/\" ql:*local-project-directories* :test #'equalp)")
" This can be done in your "
(:texttt "gdlinit.cl")
" for projects you want available during every development session. Note that you should include
the full path prefix for the directory containing the ASDF system file.")
(:item (:verbatim "(ql:quickload :gdl-yoyodyne)")
" This will compile and load the actual system. Quicklisp
uses ASDF at the low level to compile and load the systems, and
Quicklisp will retrieve any depended-upon third-party libraries from
the Internet on-demand. Source files will be compiled only if the
corresponding binary (fasl) file does not exist or is older than the
source file. By default, ASDF keeps its binary files in a "
(:emph "cache")
" directory, separated according to the CL platform and
operating system. The location of this cache is system-dependent, but
you can see where it is by observing the compile and load
process."))))
((:section :title "Customizing your Environment")
" You may customize your environment in several different ways,
for example by loading definitions and settings into your GDL
``world'' automatically when the system starts, and by specifying
fonts, colors, and default buffers (to name a few) for your emacs
editing environment."
)
((:section :title "Saving the World")
"``Saving the world'' refers to a technique of saving a complete
binary image of your GDL ``world'' which contains all the currently
compiled and loaded definitions and settings. This allows you to
start up a saved world almost instantly, without being required to
reload all the definitions. You can then incrementally compile and
load just the particular definitions which you are working on for your
development session.
To save a world, follow these steps:"
((:list :style :enumerate)
(:item "Load the base GDL code and (optionally) code for GDL
modules (e.g. gdl-yadd, gdl-tasty) you want to be in your saved
image. Note that in some implementations, this has step to be done in
a plain session without multiprocessing (i.e. without an Emacs
connection) - so you would do this loading step from a command shell
e.g. Windows cmd prompt. For example:"
(:verbatim "
(ql:quickload :gdl-yadd)
(ql:quickload :gdl-tasty)"))
(:item "(needed only for full GDL):" (:verbatim "(ff:unload-foreign-library (merge-pathnames \"smlib.dll\" \"sys:smlib;\"))"))
(:item (:verbatim "(net.aserve:shutdown)"))
(:item " (to save an image named yoyodyne.dxl) Invoke the command "
(:verbatim "(ensure-directories-exist \"~/gdl-images/\")")
(:verbatim "(uiop:dump-image dumplisp \"~/gdl-images/yoyodyne\")")
"Note that the standard extension for Allegro CL images is "
(:texttt ".dxl")
". Prepend the file name with path information, to write the image to a specific location.")))
((:section :title "Starting up a Saved World")
"In order to start up GDL using a custom saved image, or ``world,'' follow these steps"
((:list :style :enumerate)
(:item "Exit GDL")
(:item "Copy the supplied image file, e.g."
(:texttt "gdl.dxl")
" to "
(:texttt "gdl-orig.dxl")
".")
(:item "Move the custom saved dxl image to "
(:texttt "gdl.dxl")
" in the GDL application "
(:texttt "\"program/\"")
" directory.")
(:item "Start GDL as usual. Note: you may have to edit the system gdlinit.cl or your home gdlinit.cl
to stop it from loading redundant code which is already in the saved image.")))))
| 19,287 | Common Lisp | .lisp | 386 | 46.323834 | 166 | 0.714096 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | d9db5c616d650ce5b43184df9aefda2f7f8972171d8b3a16aecd750f09d62226 | 36,081 | [
-1
] |
36,082 | package.lisp | lisp-mirror_gendl/documentation/tutorial/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 :gendl-doc (:export #:assembly #:make #:make-html))
| 936 | Common Lisp | .lisp | 22 | 41.363636 | 71 | 0.756579 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 92e74dda78c39ff0625385e1d0148db79f228d91594ee7aa2a617fde3aba44e2 | 36,082 | [
-1
] |
36,083 | custom-user-interfaces.lisp | lisp-mirror_gendl/documentation/tutorial/source/custom-user-interfaces.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 :gendl-doc)
(defparameter *custom-user-interfaces*
`((:chapter :title "Custom User Interfaces in GDL")
(:p "Another strength of GDL is the ability to create custom
web-based user interfaces. GDL contains a built-in web server and
supports the creation of generative "
(:emph "web-based")
" user interfaces"
(:footnote "GDL does not contain support for native desktop
GUI applications. Although the host Common Lisp
environment (e.g. Allegro CL or LispWorks) may contain a GUI builder
and Integrated Development Environment, and you are free to use these,
GDL does not provide specific support for them.")
". Using the same "
(:texttt "define-object")
" syntax which you have already encountered, you can define
web pages, sections of web pages, and form elements.
Your UI elements generate standard HTML, CSS, JavaScript, and can use
any external client-side libraries as with any standard web application. AJAX support is
built-in, making it easy for server and UI elements to communicate asynchronously."
)
(:p "In order to create a web application in GDL, you should have a working
knowledge of the semantics of HTML, for which many explanations are available
online and in print. For syntax, you can use an HTML-generation library such as "
(:href "http://weitz.de/cl-who" "CL-WHO") (:footnote "http://weitz.de/cl-who")
" or "
(:href "http://www.franz.com/support/documentation/current/doc/aserve/htmlgen.html" "HTMLGen")
(:footnote "http://www.franz.com/support/documentation/current/doc/aserve/htmlgen.html")
", both of which are built into GDL. In this tutorial we will use CL-WHO, so in what folows,
we will assume that you are already familiar with its features as documented in "
(:href "http://weitz.de/cl-who" "http://weitz.de/cl-who") ".")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
((:section :title "Package and Environment for Web Development")
(:p "The "(:texttt ":gwl")" package"(:footnote "The acronym \"GWL\" stands
for Generative Web Language")" contains a set of primitive objects and functions provided by
GDL for building web applications.")
(:p "Similarly to "(:texttt "gdl:define-package")", you can use "(:texttt "gwl:define-package")"
to create a working package which has access to the symbols you will need for building a
web application (in addition to the other GDL symbols).")
(:p "The "(:texttt ":gwl-user")" package is pre-defined and may be used for practice
work. For real projects, you should define your own package using "(:texttt "gwl:define-package")".")
(:p "The YADD"(:footnote "YADD is accessible with "(:texttt
"http://localhost:9000/yadd")".")" reference documentation for package
GWL provides detailed specifications for all the primitive objects and functions.")
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
((:section :title "Web Page Objects")
(:p "To make a GDL object presentable as a web page, the following two
steps are needed:"
((:list :style :enumerate)
(:item "Mix " (:texttt "base-ajax-sheet") " into the object definition.")
(:item "Within the object, define the GDL message "(:texttt "main-sheet-body")" returning an HTML string.")))
(:p "As soon the object is defined, the object's page becomes accessible at the URL"
(:quote (:texttt "http://localhost:9000/make?object="(:emph "classname")))
"where "(:texttt(:emph "classname"))" is the object name (including the package name). Connecting to this
URL starts a new web server session and creates an instance of the object unique to that session"(:footnote
"This is done by redirecting the response to a unique URL identified by a "(:emph "session ID")".
The session ID is constructed from a combination of the current date and time, along with a pseudo-random number.")".
This ensures that each user of your application site will see their own specific instance of the object.")
(:p "The "(:texttt "main-sheet-body")" message can be either a computed slot or a GDL function. It should
produce a string of the HTML to be placed in the body of the page, i.e. between the "(:texttt "<body>")" and
"(:texttt "</body>")" tags. The "(:texttt "<head>")" of the page is filled in automatically by GDL, and can be
customized in various ways.")
(:p "The easiest way to produce a valid "(:texttt "main-sheet-body")" string is with the GWL convenience macro
"(:texttt "with-cl-who-string")". This is a wrapper for the CL-WHO macro "(:texttt "with-html-output")" which
additionally establishes the default environment for outputting an HTML string within a GWL application.")
(:p "Figure "(:ref "fig:gwl-hello-world")" is an example of a simple static web page."
((:boxed-figure :caption "Simple Static Page" :label "fig:gwl-hello-world")
(:small (:verbatim (:include "~/genworks/gendl/documentation/tutorial/examples/gwl-hello-world.gdl"))))
#+NOT-YET
((:image-figure :image-file "gwl-hello-world.png" :caption "Simple Static Page"
:width "4in" :height "3in"
:label "fig:gwl-hello-world-image")))
(:p "This simple framework can also be used to create dynamic content, as illustrated in figure "(:ref "fig:gwl-president-table")".
Note that CL-WHO symbols such as "(:texttt "htm")", "(:texttt "str")", and "(:texttt "fmt")" are available in GWL without
package qualification. See "(:href "http://weitz.de/cl-who" "http://weitz.de/cl-who")" for an explanation of
dynamic HTML generation in CL-WHO."
((:boxed-figure :caption "Dynamic Content Using CL-WHO" :label "fig:gwl-president-table")
(:small (:verbatim (:include "~/genworks/gendl/documentation/tutorial/examples/gwl-president-table.gdl"))))
#+NOT-YET
((:image-figure :image-file "gwl-president-table.png" :caption "Dynamic Content Using CL-WHO"
:width "4in" :height "3in"
:label "fig:gwl-president-table-image"))
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
((:section :title "Page URLs")
(:p "Objects based on "(:texttt "base-ajax-sheet")" are automatically available from the server at the
URL of the form "(:texttt "http://localhost:9000/make?object="(:emph "classname"))". This is useful during
debugging, but for real projects, you should define a more direct URL. You do that using the
CL function "(:texttt "(gwl:publish-gwl-app "(:emph "path")" "(:emph "classname")")")". For example,"
(:quote (:texttt "(gwl:publish-gwl-app \"/greeting\" \"gwl-user::hello-world\")"))
"will make the "(:texttt "gwl-user::hello-world")" object accessible at the URL "(:texttt "http://localhost:9000/greeting")"."))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
((:section :title "Page Customizations")
;;; TODO: Could illustrate customizations by adding CSS to make Hello World red. (:p :class "red" "Hello World!") and maybe
;;; javascript to change colors when click?
(:p "In addition to specifying the body html via "(:texttt "main-sheet-body")", you can
customize the page by optionally adding certain messages to your object:"
((:list :style :itemize)
(:item "Message "(:texttt "title")" can be used to specify the title of the web page")
(:item "Message "(:texttt "doctype-string")" is the string to place at the very start
of the document (it defaults to "(:texttt "\"<!DOCTYPE HTML>\"")")")
(:item "Message "(:texttt "additional-header-content")" can contain any additional
HTML you want to go into the page's "(:texttt "<head>")" section.")
(:item "Message "(:texttt "body-class")" can specify the CSS "(:texttt "class")" attribute for the "(:texttt "<body>")" tag.")
(:item "Message "(:texttt "body-onload")" can be a string of Javascript to go
into the "(:texttt "onload")" event attribute of the "(:texttt "<body>")" tag.")
(:item "Message "(:texttt "body-onpageshow")" can be a string of Javascript to go
into the "(:texttt "onpageshow")" event attribute of the "(:texttt "<body>")" tag.")))
(:p "We will be using some of these customizations in the examples below."))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
((:section :title "Debugging")
;;;TODO: what else is there to say here?
(:p ""(:texttt "base-ajax-sheet")" provides the "(:texttt "development-links")" message with
links for functionality useful during development, currently consisting of a Refresh! link and a Break
link. It is typically used as follows:"
(:verbatim "(main-sheet-body
(with-cl-who-string ()
(when *developing?* (str (the development-links)))
;; Rest of page definition goes here
...))")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
((:section :title "Page Links")
(:p "In order to allow HTML links between page objects, GDL implements a scheme that assigns
URL's to individual page instances. In order to do this efficiently, GDL maintains a table of
root-level instances, and identifies page instances relative to their root instance. For this reason,
and in order for dependency-tracking to work properly, all pages in a GDL application must belong to
the same tree, i.e. they must share a common root page object.")
(:p "You can generate a hyperlink (an "(:texttt "<A>")" tag) to a particular "(:texttt "base-ajax-sheet")" page
by invoking the "(:texttt "write-self-link")" GDL function on the page instance. "(:texttt "write-self-link")" accepts
a number of keyword arguments to customize the link:"
((:list :style :itemize)
(:item "You specify the text to be displayed as the link with the "(:texttt ":display-string")" argument")
(:item "You can direct the link to a specific anchor within the page with the "(:texttt ":local-anchor")" argument")
(:item "You can specify various tag attributes of the "(:texttt "<A>")" tag:"
((:list :style :itemize)
(:item "Argument "(:texttt ":target")" for the "(:texttt "target")" attribute")
(:item "Argument "(:texttt ":on-mouse-over")" for the "(:texttt "onmouseover")" attribute")
(:item "Argument "(:texttt ":on-mouse-out")" for the "(:texttt "onmouseout")" attribute")
(:item "Argument "(:texttt ":on-click")" for the "(:texttt "onclick")" attribute")
(:item "Argument "(:texttt ":title")" for the "(:texttt "title")" attribute")
(:item "Argument "(:texttt ":class")" for the "(:texttt "class")" attribute")
(:item "Argument "(:texttt ":id")" for the "(:texttt "id")" attribute")))))
(:p "In order to help create hierarchical multi-page sites, "(:texttt "base-ajax-sheet")" also provides
a "(:texttt "write-back-link")" GDL function for the purpose of generating a link back to the parent page object.
It accepts all the same arguments as "(:texttt "write-self-link")".")
(:p "Figure "(:ref "fig:gwl-president-links")" shows a modification of "(:ref "fig:gwl-president-table")"
where we put detailed information about each president on a separate page, and provide links to these individual
pages from a summary page. Each child page contains a link to return back to the summary."
((:boxed-figure :caption "Hyperlinking" :label "fig:gwl-president-links")
(:small (:verbatim (:include "~/genworks/gendl/documentation/tutorial/examples/gwl-president-links.gdl"))))
#+NOT-YET
((:image-figure :image-file "gwl-president-links.png" :caption "Hyperlinking"
:width "4in" :height "3in"
:label "fig:gwl-president-links-image")))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
((:section :title "Input Using Forms")
(:p "GWL provides a macro "(:texttt "with-html-form")" to obtain input from the user
with an HTML form. In the body of the form, you specify input fields using standard HTML
form controls. When the user submits the form, GDL processes the form input values in two
ways:"
((:list :style :itemize)
(:item "When the name of an form field matches the name of a "(:texttt
":settable")" computed-slot in the object, GDL will automatically infer its type, do
appropriate conversions, and set the slot the its new value"(:footnote "If the type of a slot
can vary, it is best to make its default be a string and parse the string yourself e.g. with
the "(:texttt "read-safe-string")" function.")".")
(:item "Any input values that do not match a suitable slot are available
from the "(:texttt "query-plist")" message, which returns a plist mapping
keywords representing form field names to the corresponding input value strings")))
(:p "Figure "(:ref "fig:gwl-hello-world-form")" shows how we can extend the simple
Hello World application of "(:ref "fig:gwl-hello-world")" to allow the user to
customize both the name and the greeting."
((:boxed-figure :caption "Input Using Forms" :label "fig:gwl-hello-world-form")
(:small (:verbatim (:include "~/genworks/gendl/documentation/tutorial/examples/gwl-hello-world-form.gdl"))))
#+NOT-YET
((:image-figure :image-file "gwl-hello-world-form.png" :caption "Input Using Forms"
:width "4in" :height "3in"
:label "fig:gwl-hello-world-form-image")))
((:subsection :title "Form Controls")
(:p "GDL provides a set of primitives useful for generating the
standard HTML form controls in the body of "(:texttt "with-html-form")".
These should be instantiated as child objects in the page. They provide a
"(:texttt "html-string")" message which returns the HTML for the control.")
(:p "The form controls provided by GDL are documented in YADD"(:footnote "YADD
is accessible with "(:texttt "http://localhost:9000/yadd")".")" and in the reference appendix
of this manual. Examples of available form controls are:"
((:list :style :itemize)
(:item (:texttt "text-form-control"))
(:item (:texttt "checkbox-form-control"))
(:item (:texttt "menu-form-control"))
(:item (:texttt "radio-form-control"))
(:item (:texttt "text-form-control"))
(:item (:texttt "button-form-control"))))
(:p "These form controls are customizable by mixing them into
your own specific form controls (although this often is not
necessary). New form controls such as for numbers, dates,
etc will soon be added to correspond to latest HTML
standards.")
#+old (:p "Figure "(:ref "fig:gwl-3b")" is an example which allows the user to enter a year,
and the application will respond with the revenue amount for that year. Additional
form controls are also provided to adjust the table border and cell padding.
This example, when instantiated in a web browser, might look as shown in Figure "(:ref
"fig:gwl-3b-image")"."
((:boxed-figure :caption "Using Form Controls"
:label "fig:gwl-3b")
(:tiny (:verbatim (:include "~/genworks/gendl/documentation/tutorial/examples/gwl-3b.gdl"))))
((:image-figure :image-file "gwl-3b.png" :caption "Using Form Controls"
:width "4in" :height "3in"
:label "fig:gwl-3b-image")))
(:p "Figure "(:ref "fig:gwl-hello-world-controls")" reimplements the Hello World form from the last section
using form controls. The functionality is the same but the source is shorter and simpler to read and understand."
((:boxed-figure :caption "Using Form Controls" :label "fig:gwl-hello-world-controls")
(:small (:verbatim (:include "~/genworks/gendl/documentation/tutorial/examples/gwl-hello-world-controls.gdl"))))
)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
((:section :title "Interactive Applications using AJAX")
(:p "Input using traditional HTML forms requires the user to explicitly \"submit\" each update
request, and then the application responds by reloading the whole page. The "(:href
"http://en.wikipedia.org/wiki/Ajax_(programming)" "AJAX")(:footnote
"http://en.wikipedia.org/wiki/Ajax_(programming)")" methodology allows web
applications to autonomously contact the server, and to change page content dynamically in
response, leading to a more interactive user experience.")
(:p "GDL has built-in support for AJAX, using its usual convenient generative approach.
You use child objects to model independently updatable sections of the web pgae, and the dependency
tracking engine which is built into GDL automatically manages of which sections of the
page need to be updated after a request.")
(:p "Moreover, the state of the internal GDL model which
represents the page and the page sections is kept identical to the
displayed state of the page. This means that if the user hits the
``Refresh'' button in the browser, the state of the page will remain
unchanged. This ability is not available in some other AJAX
frameworks.")
((:subsection :title "AJAX Event Handling")
(:p "An AJAX application works by contacting the server
in response to "(:href "https://en.wikipedia.org/wiki/DOM_events" "HTML events")
(:footnote "https://en.wikipedia.org/wiki/DOM_events")" such as \"onclick\"
or \"onfocus\". GDL provides the function "(:texttt "gdl-ajax-call")" to generate
the JavaScript to handle such events by invoking GDL functionality on the server.")
(:p "For example, the following CL-WHO snippet"
(:verbatim "((:span :onclick (the (gdl-ajax-call :function-key :restore-defaults!)))
\"Press Me\")")
"will produce a piece of text ''Press Me'' which, when pressed, will call "(:texttt "restore-defaults!")"
in the page's object on the server. If "(:texttt "restore-defaults!")" is not defined, an error will result.")
(:p (:texttt "gdl-ajax-call")" can also update form control values on the server by using the "(:texttt
":form-controls")" keyword argument. For details, see the "(:texttt "gdl-ajax-call")" documentation in
YADD"(:footnote "YADD is accessible with "(:texttt "http://localhost:9000/yadd")".")" and the reference appendix.")
(:p "For convenience, GDL form-control objects provide direct support for AJAX with the "(:texttt ":ajax-submit-on-change?")"
argument, which is equivalent to invoking "(:texttt "gdl-ajax-call")" for the control's \"onchange\" event."))
((:subsection :title "AJAX Page Updating")
(:p "In order to have the capacity to change itself in response to AJAX calls, a page must be structured
as one or more "(:texttt "sheet-section")" child objects. Sheet sections provide a "(:texttt "main-div")" message
which computes the HTML for the section and registers the section as subject to AJAX update handling. The
main page should include the "(:texttt "main-div")" of each child sheet section in its "(:texttt "main-sheet-body")".")
(:p "The sheet section definition should specify the section's HTML in the "(:texttt "inner-html")" input slot.
This plays the same role as the "(:texttt "main-sheet-body")" does in the page.")
(:p "Figure "(:ref "fig:gwl-hello-world-ajax")" reimplements the Hello World form from the last section
using AJAX. Note that we don't need the explicit UPDATE button any more, as the changes the user makes take effect
immediately due to the use of "(:texttt ":ajax-submit-on-change?")" argument in each of the form controls."
((:boxed-figure :caption "Using AJAX"
:label "fig:gwl-hello-world-ajax")
(:small (:verbatim (:include "~/genworks/gendl/documentation/tutorial/examples/gwl-hello-world-ajax.gdl"))))
)
)
((:subsection :title "Including Graphics")
(:p "The fundamental mixin or child type to make a graphics viewport is "
(:texttt "base-ajax-graphics-sheet")
". This object definition takes several optional input-slots, but the most essential are the "
(:texttt ":display-list-objects") " and the "
(:texttt ":display-list-object-roots")
". As indicated by their names, you specify a list of nodes to include in
the graphics output with the "
(:texttt ":display-list-objects")
", and a list of nodes whose "
(:texttt "leaves")
" you want to display in the graphics output with the "
(:texttt ":display-list-object-roots")
". View controls, rendering format, action to take when clicking on objects, etc,
can be controlled with other optional input-slots.")
((:boxed-figure :caption "Including Graphics in a Web Page"
:label "fig:gwl-5")
(:tiny (:verbatim (:include "~/genworks/gendl/documentation/tutorial/examples/gwl-5.gdl"))))
((:image-figure :image-file "gwl-5.png" :caption "Including Graphics"
:width "5in" :height "4in"
:label "fig:gwl-5-image"))
(:p "The example in Figure " (:ref "fig:gwl-5")
" contains a simple box with two graphics viewports
and ability to modify the length, height, and and width of the box:")
(:p "This will produce a web browser output similar to what is shown in Figure "
(:ref "fig:gwl-5-image")
".")
(:p "Note the following from this example:"
((:list :style :itemize)
(:item "The " (:texttt "(:use-raphael? t)") " enables raphael for SVG or VML output.")
(:item "The " (:texttt ":raphael") " image-format generates SVG or VML, depending on the browser.")
(:item "We conditionally include development-links for full Update and SetSelf! actions.")
(:item "We include two viewports in the " (:texttt "main-sheet-body") ", elements from a sequence of size 2.")
(:item "In the inputs-section, we use
the " (:texttt "html-string") " message from each
form-control to display the default
decoration (prompt, etc).")))
))))
| 22,870 | Common Lisp | .lisp | 323 | 64.603715 | 136 | 0.682177 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 088324e474678459275990eea82531707dbf56381d045586e9b4b9890a137cac | 36,083 | [
-1
] |
36,084 | introduction.lisp | lisp-mirror_gendl/documentation/tutorial/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 :gendl-doc)
(defparameter *introduction*
`((:chapter :title "Introduction")
((:section :title "Welcome")
"Congratulations on your decision to work with Genworks\\textsuperscript{\\textregistered} GDL\\texttrademark"
(:footnote "From time to time, you will also see references to
``Gendl.'' This refers to ``The Gendl Project'' which is the name of
an open-source software project from which Genworks GDL draws for its
core technology. ``The Gendl Project'' code is free to use for any
purpose, but it is released under the Gnu Affero General Public
License, which stipulates that applications code compiled with The
Gendl Project compiler must be distributed as open-source under a
compatible license (if distributed at all). Commercial Genworks GDL,
properly licensed for development and/or runtime distribution, does
not have this ``copyleft'' open-sourcing requirement.")
". By investing time to learn this system you will be investing
in your future productivity and, in the process, you will be joining a
quiet revolution. Although you may have come to Genworks GDL because
of an interest in 3D modeling or mechanical engineering, you will find
that a whole new world, and a unique approach to "
(:emph "computing")
", will now be at your fingertips as well.")
((:section :title "Knowledge Base Concepts According to Genworks")
"You may have an idea about Knowledge Base Systems,
or Knowledge "
(:emph "Based")
" Systems, from college textbooks or corporate marketing
literature, and concluded that the concepts were too broad to be of
practical use. Or you may have heard criticisms implicit in the
pretentious-sounding name, ``Knowledge-based Engineering,'' as in:
``you mean as opposed to "
(:indexed "Ignorance-based Engineering")
"?''
To provide a clearer picture, we hope you will concur that Genworks'
concept of a KB system is straightforward, relatively uncomplicated,
and practical. In this manual our goal is to make you both comfortable
and motivated to explore the ideas we have built into our flagship
system, Genworks GDL.
Our informal definition of a "
(:emph (:indexed "Knowledge Base System"))
" is a hybrid "
(:emph "Object-Oriented")
(:footnote "An " (:emph "Object-Oriented")
" programming environment supports named collections
of values along with procedures to operate on those
values, including the possibility to
modify (``mutate'') the data. See
https://en.wikipedia.org/wiki/Object-oriented_programming")
" and "
(:emph "Functional")
(:footnote "A pure " (:emph "Functional")
" programming environment supports only the
evaluation of Functions which work by computing results, but do not
modify (i.e. ``mutate'') the in-memory state of any objects. See
http://en.wikipedia.org/wiki/Functional_programming")
" programming environment, which implements the features of "
(:emph (:indexed "Caching"))
" and "
(:emph (:indexed "Dependency tracking"))
". Caching means that once the KB system has computed
something, it generally will 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")
", in order to give a fresh result.")
((:section :title "Classic Definition of Knowledge Based Engineering (KBE)")
"Sections "
(:ref "sec:classicdefinitionofknowledgebasedengineering(kbe)")
" through "
(:ref "sec:object-orienteddesign")
" are sourced from "
(:cite "LaRocca")
"."
(:quote
"Knowlege based engineering (KBE) is a technology predicated on
the use of dedicated software tools called KBE systems, which are able
to capture and systematically re-use product and process engineering
knowledge, with the final goal of reducing the time and costs of
product development by means of the following:"
(:ul (:li "Automation of repetitive and non-creative design tasks;")
(:li "Support of multidisciplinary design optimization in all
phases of the design process"))))
((:section :title "Runtime Value Caching and Dependency Tracking")
(:quote
(:p "Caching refers to the ability of the KBE system to memorize at
runtime the results of computed values (e.g. computed slots and
instantiated objects), so that they can be reused when required,
without the need to re-compute them again and again, unless necessary.
The dependency tracking mechanism serves to keep track of the current
validity of the cached values. As soon as these values are no longer
valid (stale), they are set to unbound and recomputed if and only at
the very moment they are again demanded.")
(:p "This dependency tracking mechanism is at the base of
associative modeling, which is of extreme interest for engineering
design applications. For example, the shape of a wing rib can be
defined according to the shape of the wing aerodynamic surface. In
case the latter is modified, the dependency tracking mechanism will
notify the system that the given rib instance is no longer valid and
will be eliminated from the product tree, together with all the
information (objects and attributes) depending on it. The new rib
object, including its attributes and the rest of the affected
information, will not be re-instantiated/updated/re-evaluated
automatically, but only when and if needed (see demand driven
instantiation in the next section)")))
((:section :title "Demand-Driven Evaluation")
(:quote
"KBE systems use the "
(:emph "demand-driven")
" approach. That is, they evaluate only those chains of
expressions required to satisfy a direct request of the user (i.e. the
evaluation of certain attributes for the instantiation of an object),
or the indirect requests of another object, which is trying to satisfy
a user demand. For example, the system will create an instance of the
rib object only when the weight of the abovementioned wing rib is
required. The reference wing surface will be generated only when the
generation of the rib object is required, and so on, until all the
information required to respond to the user request will be made
available.
It should be recognized that a typical object tree can be structured
in hundreds of branches and include thousands of attributes. Hence,
the ability to evaluate "
(:emph "specific")
" attributes and product model branches at demand, without the
need to evaluate the entire model from its root, prevents waste of
computational resources and in many cases brings seemingly intractible
problems to a rapid solution."))
((:section :title "Object-oriented Systems")
(:quote "An object-oriented system is composed of
objects (i.e. concrete instantiations of "
(:emph "named")
" classes), and the behavior of the system results from
the collaboration of those objects. Collaboration between
objects involves them sending messages to each other. Sending a
message differs from calling a function in the sense that when
a target object receives a message, it decides on its own what
function to carry out to service that message. The same message
may be implemented by many different functions, the one
selected depending on the current state of the target
object."))
((:section :title "Object-oriented Analysis")
(:quote
(:p "Object-oriented analysis (OOA) is the process of analyzing
a task (also known as a problem domain) to develop a conceptual
model that can then be used to complete that task. A typical OOA
model would describe computer software that could be used to
satisfy a set of customer-defined requirements. During the
analysis phase of problem-solving, the analyst might consider a
Written Requirements Statement, a formal vision document, or
interviews with stakeholders or other interested parties. The
task to be addressed might be divided into several subtasks (or
domains), each representing a different business,
technological, or other area of interest. Each subtask would be
analyzed separately. Implementation
constraints (e.g. concurrency, distribution, persistence, or
how the system is to be built) are not considered during the
analysis phase; rather, they are addressed during
the object-oriented design (OOD) phase.")
(:p "The conceptual model that results from OOA will typically consist of a
set of use cases, one or more UML class diagrams, and a number of
interaction diagrams. It may also include some form of user interface.")))
((:section :title "Object-oriented Design")
(:quote
"During the object-oriented design (OOD) phase, a developer
applies implementation constraints to the conceptual model produced in
the object-oriented analysis. Such constraints could include not only
those imposed by the chosen architecture but also any non-functional
--- technological or environmental --- constraints, such as data
processing capacity, response time, run-time platform, development
environment, or those inherent in the programming language. Concepts
in the analysis model are mapped onto implementation classes and
interfaces resulting in a model of the solution domain, i.e., a
detailed description of "
(:emph "how")
" the system is to be built."))
((:section :title "The Object-Oriented Paradigm meets the Functional paradigm")
"In order to model very complex products and efficiently manage
large bodies of knowledge, KBE systems tap the potential of the object
oriented nature of their underlying language (e.g. Common
Lisp). ``Object'' in this context refers to an instantiated data
structure "
(:emph "of a particular assigned data type")
". As is well-known in the computing community, unrestricted
modification of the state of objects leads to unmaintainable systems
which are difficult to debug. KBE systems manage this drawback by
strictly controlling and constraining any ability to modify or
``change state'' of objects.
In essence, a KBE system generates a tree of inspectable objects which
is analogous to the function call tree of pure functional-language
systems.")
((:section :title "Goals for this Manual")
"This manual is designed as a companion to a live two-hour
GDL/GWL tutorial, but you may also be relying on it independently of
the tutorial. Portions of the live tutorial are available in
``screencast'' video form, in the Documentation section of "
(:texttt "http://genworks.com")
" In any case, our fundamental goals of this Manual are:"
((:list :style :itemize)
(:item "To get you motivated about using Genworks GDL")
(:item "Enable you to ascertain whether Genworks GDL is an appropriate tool for a given job")
(:item "Equip you with the ability to state the case for using GDL/GWL when appropriate")
(:item "Prepare you to begin authoring and maintaining GDL
applications, or porting apps from similar KB systems into GDL."))
"The manual will begin with an introduction to the "
(:indexed "Common Lisp")
" programming language. If you are new to Common Lisp: welcome!
You are about to be introduced to a powerful tool backed by a
rock-solid body of standard specifications, which will protect your
development investment for decades to come. In addition to the
overview provided in this manual, 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 written by the author. ")
((:section :title "What is GDL?")
"GDL is an acronym for
``General-purpose Declarative Language.''"
(:ul
(:li "In a nutshell, GDL is a system for creating custom,
targeted CAD systems and other applications. By ``targeted,''
we mean these end-user CAD systems and applications are
designed to complete a specific, rule-based set of design
tasks, as distinct from a general-purpose CAD system which
works as an electronic drafting board or interactive 3D
modeling system.")
(:li
"GDL is a superset of ANSI Common Lisp, and consists largely of
automatic code-expanding extensions to Common Lisp implemented in the
form of macros. When you write, for example, 20 lines in GDL, you
might be writing the equivalent of 200 lines of Common Lisp. Given
that GDL is a superset of Common Lisp, you of course retain the
full power of the CL language at your disposal whenever you are
working in GDL.")
(:index "compiled language!benefits of")
(:index "macros!code-expanding")
(:li
"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 from some other so-called KB systems
on the market, which are essentially nothing more than interpreted "
(:emph "scripting languages")
" which often impose arbitrary limits on
the size and complexity of the application].")
(:li "GDL is also a "
(:emph (:indexed "declarative"))
" language in the fullest sense. When you put together a
GDL application, you think and write mainly in terms of "
(:emph "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, and so forth. Those details are managed
automatically by the embedded language.")
(:li "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'' complexities"))
(:index "object-orientation!message-passing")
(:index "object-orientation!generic-function"))
(:li "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, you are free to use
the Generic Function paradigm. Do not be concerned at this point if
you are not fully conversant with the differences between Message
Passing and Generic Function models of object-orientation."
(:footnote "See Paul Graham's "
(:underline "ANSI Common Lisp")
", page 192, for an excellent discussion of the Two Models
of Object-oriented Programming. Peter Siebel's "
(:underline "Practical Common Lisp")
" also covers the topic; see http://www.gigamonkeys.com/book/object-reorientation-generic-functions.html.")
".")))
((:section :title "Why GDL (i.e., what is GDL good for?)")
((:list :style :itemize)
(:item "Organizing and integrating large amounts of
information in ways which are impossible or impractical using
conventional languages, CAD systems, and/or database technology
alone;")
(:item "Evaluating many design or engineering alternatives and
performing various kinds of optimizations within specified design
spaces, and doing so "
(:emph "very rapidly;"))
(:item
"Capturing, i.e., implementing, the procedures and rules used
to solve repetitive tasks in engineering and other fields;")
(:item
"Applying rules you have specified 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, and it can generate "
(:emph "applications")
" which can be considered as special-purpose CAD systems);")
(: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 qualify
as such);")
(:item "An Expert System Shell (although one could be easily embedded within it).")))
"Without further description, let's turn the page and get
started with hands-on GDL..."))
| 17,815 | Common Lisp | .lisp | 330 | 49.906061 | 117 | 0.751783 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 7d186c54cf09d7739d97db647e5d3cb3bdd019d4f4eff882dd5425033d86fd57 | 36,084 | [
-1
] |
36,085 | tasty-environment.lisp | lisp-mirror_gendl/documentation/tutorial/source/tasty-environment.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 :gendl-doc)
(defparameter *tasty-environment*
`((:chapter :title "The Tasty Development Environment")
(:p (:emph "Tasty")
(:footnote "``Tasty'' is an acronym of acronyms - it stands
for TAtu with STYle (sheets), where tatu comes from Testing And
Tracking Utility.")
" is a web based testing and tracking utility. Note that Tasty is
designed for developers of GDL applications --- that is, it is not intended
as an end-user application interface (see Chapter "
(:ref "chap:customuserinterfacesingdl")
" for the recommended steps to create end-user interfaces).")
(:p "Tasty allows one to visualize and inspect any object defined
in GDL which mixes at least "
(:texttt "base-object")
" into the definition of its root"
(:footnote "base-object is the core mixin for all geometric
objects and gives them a coordinate system, length, width, and
height. This restriction in Tasty will be eliminated in a future GDL
release so the user will be able to instantiate non-geometric
root-level objects in Tasty as well, for example to inspect objects
which generate a web page but no geometry."))
(:p "First, make sure you have compiled and loaded the code for
the Chapter 5 examples, contained in "
(:verbatim ".../src/documentation/tutorial/examples/chapter-5/")
" in your GDL distribution. If you are not sure how to do this,
you may want to leave this section temporarily and review Chapter "
(:ref "chap:basicoperationofthegdlenvironment")
", and then return.")
(:p "Now you should have the Chapter 5 example definitions
compiled and loaded into the system. To access Tasty, point your web
browser to the URL in figure"
(:ref "fig:tasty-toplevel-url")
"."
((:boxed-figure :caption "Web Browser address for Tasty development environment"
:label "fig:tasty-toplevel-url")
(:verbatim "
http://<host>:<port>/tasty
;; for example:
http://localhost:9000/tasty"))
"This will produce the start-up page, as seen in Figure "
(:ref "fig:tasty-startup")
(:footnote "This page may look slightly different, e.g. different
icon images, depending on your specific GDL version.")
". To access an instance of a specific object definition,
you specify the class package and the object type, separated by a
colon (``:'') (or a double-colon (``::'') in the event the symbol
naming the type is not exported from the package). For example,
consider the simple "
(:texttt "tower1")
" definition in Figure "
(:ref "fig:tower-source")
". This definition is in the "
(:texttt ":gdl-user")
" package. Consequently, the specification will be "
(:texttt "gdl-user:tower1"))
((:image-figure :image-file "tasty-start.png"
:caption "Tasty start-up"
:label "fig:tasty-startup"))
(:p "Note that if the "
(:texttt "assembly")
" symbol had not been exported from the "
(:texttt ":chapter-5")
" package, then a double-colon would have been needed: "
(:texttt "chapter-5::tower1")
(:footnote"use of a double-colon indicates dubious coding
practice, because it means that the code in quesion is accessing the
``internals'' or ``guts'' of another package, which may not have been
the intent of that other package's designer."))
(:p "After you specify the class package and the object type and
press the ``browse'' button, the browser will produce the Tasty
interface with an instance of the specified type. The utility
interface by default is composed of three toolbars and three view
frames (tree frame, inspector frame and viewport frame ``graphical
view port'').")
((:subsection :title "The Toolbars")
(:p "The first toolbar consists of two ``tabs'' which allow the
user to select between the display of the application itself or the
GDL reference documentation.")
(:p "The second toolbar is designed to select various ``click modes'' for
objects and graphical viewing, and to customize the interface in other
ways. It hosts five menus: edit, tree, view, windows and
help"
(:footnote "A File menu will be added in a future release, to
facilitate saving and restoring of instance ``snapshots'' --- at
present, this can be done programmatically.") ".")
(:p "The "
(:emph "tree menu")
" allows the user to customize the ``click mode'' of the
mouse (or ``tap mode'' for other pointing devices) for objects in the
tree, inspector, or viewport frames. The behavior follows the "
(:emph "select-and-match")
" behavior -- you first "
(:emph "select")
" a mode of operation with one of the buttons or menu items,
then "
(:emph "match")
" that mode to any object in the tree frame or inspector frame by
left-clicking (or tapping). These modes are as follows:")
((:list :style :itemize)
(:item (:underline "Tree: Graphical modes")
((:list :style :description)
((:item :word "Add Node (AN)")
"Node in graphics viewport")
((:item :word "Add Leaves (AL)")
"Add Leaves in graphics viewport")
((:item :word "Add Leaves indiv. (AL*)")
"Add Leaves individually (so they can be deleted individually).")
((:item :word "Draw Node (DN)")
"Draw Node in graphics view port (replacing any existing).")
((:item :word "Draw Leaves (DL)")
"Draw Leaves in graphics view port (replacing any existing).")
((:item :word "Clear Leaves (DL)")
"Delete Leaves")))
(:item (:underline "Tree: Inspect & debug modes")
((:list :style :description)
((:item :word "Inspect object (I)")
"Inspect (make the inspector frame to show the selected object).")
((:item :word "Set self to Object (B)")
"Sets a global "
(:texttt "self")
" variable to the selected object, so you can interact by sending messages to the object at the command prompt e.g. by typing "
(:texttt "(the length)")
" or "
(:texttt "(the children)")
".")
((:item :word "Set Root to Object (SR)")
"Set displayed root in Tasty tree to selected object.")
((:item :word "Up Root (UR!)")
"Set displayed root in Tasty tree up one level (this is grayed out if already on root).")
((:item :word "Reset Root (RR!)")
"Reset displayed root in Tasty to to the true root of the tree (this is grayed out if already on root).")))
(:item (:underline "Tree: frame navigation modes")
((:list :style :description)
((:item :word "Expand to Leaves (L)") "Nodes expand to their deepest leaves when clicked. ")
((:item :word "Expand to Children (C)") "Nodes expand to their direct children when clicked.")
((:item :word "Auto Close (A)") "When any node is clicked to expand, all other nodes close automatically.")
((:item :word "Remember State (R)") "Nodes expand to their previously expanded state when clicked.")))
(:item (:underline "View: Viewport Actions")
((:list :style :description)
((:item :word "Fit to Window!") "Fits to the graphics viewport size the displayed objects (use after a Zoom)")
((:item :word "Clear View! (CL!)") "Clear all the objects displayed in the graphics viewport.")))
(:item (:underline "View: Image Format")
((:list :style :description)
((:item :word "PNG")
"Sets the displayed format in the graphics viewport to PNG (raster image with
isoparametric curves for surfaces and brep faces).")
((:item :word "JPEG")
"Sets the displayed format in the graphics viewport to JPEG
(raster image with isoparametric curves for surfaces and brep faces).")
((:item :word "VRML/X3D")
"Sets the displayed format in the graphics viewport to
VRML with default lighting and viewpoint (these can be changed
programmatically). This requires a compatible plugin such as BS Contact")
((:item :word "X3DOM")
"This experimental mode sets the displayed format in the graphics viewport to use the x3dom.js Javascript library,
which attempts to render X3D format directly in-browser without the need for plugins. This works best in WebGL-enabled
browsers such as a recent version of Google Chrome"
(:footnote "Currently, it is necessary to ``Reload'' or
``Refresh'' the browser window to display the geometry in
this mode.")
".")
((:item :word "SVG/VML")
"Sets the displayed format in the graphics viewport to SVG/VML"
(:footnote "For complex objects with many display curves,
SVG/VML can overwhelm the JavaScript engine in the web
browser. Use PNG for these cases.")
", which is a vector graphics image format displaying
isoparametric curves for surfaces and brep faces.")))
(:item (:underline "View: Click Modes")
((:list :style :description)
((:item :word "Zoom in")
"Sets the mouse left-click in the graphics viewport to zoom in.")
((:item :word "Zoom out")
"Sets the mouse left-click in the graphics viewport to zoom out.")
((:item :word "Measure distance")
"Calculates the distance between two selected points from the graphics viewport.")
((:item :word "Get coordinates")
"Displays the coordinates of the selected point from the graphics viewport.")
((:item :word "Select Object")
"Allows the user to select an object from the graphics
viewport (currently works for displayed curves and
in SVG/VML mode only).")))
(:item (:underline "View: Perspective")
((:list :style :description)
((:item :word "Trimetric")
"Sets the displayed perspective in the graphics viewport to trimetric.")
((:item :word "Front")
"Sets the displayed perspective in the graphics viewport to Front (negative Y axis).")
((:item :word "Rear")
"Sets the displayed perspective in the graphics viewport to Rear (positive Y axis).")
((:item :word "Left")
"Sets the displayed perspective in the graphics viewport to Left (negative X axis).")
((:item :word "Right")
"Sets the displayed perspective in the graphics viewport to Right (positive X axis).")
((:item :word "Top")
"Sets the displayed perspective in the graphics viewport to Top (positive Z axis).")
((:item :word "Bottom")
"Sets the displayed perspective in the graphics viewport to Bottom (negative Z axis)."))))
(:p "The third toolbar hosts the most frequently used
buttons. These buttons have tooltips which will pop up when you hover
the mouse over them. However, these buttons are found in the second
toolbar as well, except for line thickness and color buttons. The line
thickness and color buttons"
(:footnote "The design of the line thickness and color
buttons is being refined and may appear differently in your
installation.")
" expand and contract when clicked, and allows the user to
select a desired line thickness and color for the objects displayed in
the graphics viewport."))
((:subsection :title "View Frames")
(:p "The " (:emph "tree frame")
" contains a hierarchical representation of your defined
object. ")
(:p "To draw the graphics (geometry) for the tower leaf-level
objects, you can select the ``Add Leaves (AL)'' item from the Tree
menu, then click the desired leaf to be displayed from the
tree. Alternatively, you can select the ``rapid'' button from the
third toolbar which is symbolized by a pencil icon. Because this
operation (draw leaves) is frequently used, the operation is also
directly available as a direct-click icon which will appear when you
hover the mouse over any leaf or node in the tree.")
(:p "A direct-click icon is also available for ``inspect
object,'' as the second icon when you hover the mouse over a leaf or
node.")
(:p "The ``inspector'' frame allows the user to inspect (and in
some cases modify) the object instance being inspected.")
(:p "For example, we can make the "
(:texttt "number-of-blocks")
" of the tower to be ``settable,'' by adding the keyword "
(:texttt ":settable")
" after its default expression (please stay tuned for a Chapter "
" on Advanced GDL if you are interested in more details on this GDL
syntax). We will also pass in the number-of-blocks as the :size of
the "
(:texttt "blocks")
" sequence, rather than using a hard-coded value as
previously. The new assembly definition is now:"
(:verbatim ";;
;; FLAG -- insert verbatim or ref to new tower code
;; "))
(:p "In this new version of the tower, the number-of-blocks is a
settable slot, and its value can be modified (i.e. ``bashed'') as
desired, either programmatically from the command-line, in an end-user
application, or from the Tasty environment.")
(:p "To modify the value in Tasty: select ``Inspect'' mode from the Tree
menu, then select the root of the "
(:texttt "assembly")
" tree to set the inspector on that object. Once the
inspector is displaying this object, it is possible to expand its
settable slots by clicking on the ``Show Settables!'' link (use the
``X'' link to collapse the settable slots view). When the settable
slots area is open, the user may set the values as desired by
inputting the new value and pressing the OK button."))))
| 13,769 | Common Lisp | .lisp | 274 | 46.945255 | 130 | 0.725037 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 962ad4ce40d72e20855a0e4c1812b2448ac8cf309a2d180ba15a5924b7be153d | 36,085 | [
-1
] |
36,086 | gendl-geometry.lisp | lisp-mirror_gendl/documentation/tutorial/source/gendl-geometry.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 :gendl-doc)
(defparameter *gendl-geometry*
`((:chapter :title "Working with Geometry in GDL")
(:p "Although Genworks GDL is a powerful framework for a variety
of general-purpose undertakings, one of its particular strong points
is generating geometry and processing geometric entities. Geometric
capabilities are provided by a library of "
(:emph "low-level primitives")
", or LLPs. LLPs are pre-defined GDL objects which you can
extend by ``mixing in'' with your own definitions, and/or
instantiate as child objects in your definitions.")
(:p "The names of the geometric LLPs are in the "
(:texttt ":geom-base")
" package, and here are some examples:"
((:list :style :itemize)
(:item (:texttt "base-coordinate-system") " provides an empty 3D Cartesian coordinate system."
(:footnote (:texttt "base-coordinate-system") " is also known by its legacy name "
(:texttt "base-object")))
(:item "Simple 2-dimensional primitives include "
(:texttt "line")
", "
(:texttt "arc")
", and " (:texttt "ellipse") ".")
(:item "Simple 3-dimensional primitives include "
(:texttt "box")
", "
(:texttt "sphere")
", and "
(:texttt "cylinder")
".")
(:item "Advanced 3-dimensional primitives (which depend on optional add-on Geometry Kernel module) include "
(:texttt "b-spline-curve")
", "
(:texttt "b-spline-surface")
", and "
(:texttt "merged-solid") "."))
"This chapter will cover the default coordinate system of GDL as well as the built-in simple 2D and 3D LLPs. Chapter "
(:ref "chap:workingwithsurfacesandsolids")
" will cover the advanced Surfaces and Solids primitives.")
((:section :title "The Default Coordinate System in GDL")
(:p "GDL's default coordinate system comes with the standard mixin "
(:texttt "base-coordinate-system")
" and represents a standard three-dimensional Cartesian
Coordinate system with X, Y, and Z dimensions.")
((:image-figure :image-file "coord-sys-tri.png" :caption "Coordinate System in Trimetric View"
:width "3in" :height "3in"
:label "fig:coord-sys-tri"))
((:image-figure :image-file "coord-sys-front.png" :caption "Coordinate System in Front View"
:width "3in" :height "3in"
:label "fig:coord-sys-front"))
((:image-figure :image-file "coord-sys-top.png" :caption "Coordinate System in Top View"
:width "3in" :height "3in"
:label "fig:coord-sys-top"))
((:image-figure :image-file "coord-sys-labeled-faces.png" :caption "Coordinate System with Symbolically Labeled Faces"
:width "3in" :height "3in"
:label "fig:coord-sys-labeled-faces"))
(:p "Figure " (:ref "fig:coord-sys-tri") " shows the coordinate system in a 3D Trimetric view.")
(:p "Figure " (:ref "fig:coord-sys-front") " shows the coordinate system in a Front View.")
(:p "Figure " (:ref "fig:coord-sys-top") " shows the coordinate system in a Top View.")
(:p "Figure " (:ref "fig:coord-sys-labeled-faces") " shows each face of the reference box labeled with its symbolic direction:"
((:list :style :itemize)
(:item (:texttt "Right") " for the " (:textbf "positive X") " direction")
(:item (:texttt "Left") " for the " (:textbf "negative X") " direction")
(:item (:texttt "Rear") " for the " (:textbf "positive Y") " direction")
(:item (:texttt "Front") " for the " (:textbf "negative Y") " direction")
(:item (:texttt "Top") " for the " (:textbf "positive Z") " direction")
(:item (:texttt "Bottom") " for the " (:textbf "negative Z") " direction"))))
((:section :title "Building a Geometric GDL Model from LLPs")
"The simplest geometric entity in GDL is a "
(:texttt "box")
", and in fact all entities are associated with an imaginary "
(:emph "reference box")
" which shares the same slots as a normal box. The "
(:texttt "box")
" primitive type in GDL inherits its inputs from "
(:texttt "base-coordinate-system")
", and the fundamental inputs are:"
((:list :style :itemize)
(:item (:texttt "center") " Default: " (:texttt "#(0.0 0.0 0.0)"))
(:item (:texttt "orientation") " Default: " (:texttt "nil"))
(:item (:texttt "height") " Default: " (:texttt "0"))
(:item (:texttt "length") " Default: " (:texttt "0"))
(:item (:texttt "width") " Default: " (:texttt "0")))
(:p "Figure "
(:ref "fig:box-code")
" defines an example box, and Figure "
(:ref "fig:tasty-box")
" demonstrates how it will display in Tasty.")
(:p "Note the following from the example in "
(:ref "fig:box-code")
":"
((:list :style :itemize)
(:item "The symbol "
(:texttt "+phi+")
(:footnote "By convention, constants in Common Lisp are
named with a leading and trailing "
(:texttt "+")
" as a way to make them recognizable as constants.")
" holds a global constant containing the ``golden ratio''
number, which is approximated as 1.618.")
(:item "The slots "
(:texttt "length")
", "
(:texttt "width")
", and "
(:texttt "height"))
" are defined in "
(:texttt "base-object")
" as "
(:emph "trickle-down-slots")
". For this reason they are automatically being passed down
into into the "
(:texttt "box")
" child object. Therefore it is not necessary to pass them down explicitly."))
((:boxed-figure :caption "Definition of a Box" :label "fig:box-code")
(:verbatim (:include "~/genworks/gendl/documentation/tutorial/examples/box-1.gdl")))
((:image-figure :image-file "tasty-box-1.png" :caption "Simple box displayed in Tasty"
:width "4in" :height "3in"
:label "fig:tasty-box"))
((:subsection :title "Positioning a child object using the center input")
((:rendered-figure :caption "Positioned Boxes" :object "positioned-boxes"))
(:p "By default, a child object will be positioned at the same "
(:texttt "center")
" as its parent, and the "
(:texttt "center")
" defaults to the point "
(:texttt "#(0.0 0.0 0.0)")
". Figure "
(:ref "fig:positioned-boxes-source")
" (rendered in Figure "
(:ref "fig:positioned-boxes")
") shows a second box being positioned adjacent to the first, by using the "
(:texttt ":center")
" input. "))
((:subsection :title "Positioning Sequence Elements using (the-child index)")
"When specifying a sequence of child objects, each individual sequence element
can be referenced from within its "
(:texttt ":objects")
" section using the operator "
(:texttt "the-child")
". By using "
(:texttt "the-child")
" to send the "
(:texttt "index")
" message, you can obtain the index"
(:footnote "Indices in GDL ``size'' sequences are integers which start with 0 (zero).")
" of each individual child object as it is being processed.
In this manner it is possible to compute a distinct position for each child, as a function of its
index, as demonstrated in Figures "
(:ref "fig:positioned-by-index-source")
" and "
(:ref "fig:positioned-by-index")
"."
((:rendered-figure :caption "Positioned by Index"
:object "positioned-by-index")))
((:subsection :title "Relative positioning using the translate operator")
(:p "It is usually preferable to position child objects in a "
(:emph "relative")
" rather than "
(:emph "absolute")
" manner with respect to the parent. For example, in our positioned-by-index example in Figure "
(:ref "fig:positioned-by-index-source")
", each child box object is being positioned using an absolute coordinate produced by "
(:texttt "make-point")
". This will work as long as the center of the current parent is "
(:texttt "#(0.0 0.0 0.0)")
" (which it is, by default). But imagine if this parent
itself is a child of a larger assembly. Imagine further that the
larger assembly specifies a non-default center for this instance
of "
(:texttt "positioned-by-index")
". At this point, the strategy fails.")
(:p "The solution is to adhere to a consistent Best Practice of positioning child objects according to the "
(:texttt "center")
" (or some other known datum point) of the parent
object. This can easily be accomplished through the use of
the "
(:emph "translate")
" operator. The "
(:texttt "translate")
" operator works within the context of a GDL object, and
allows a 3D point to be translated in up to three directions, selected from: "
(:texttt ":up")
", "
(:texttt ":down")
", "
(:texttt ":left")
", "
(:texttt ":right")
", "
(:texttt ":front")
", "
(:texttt ":rear")
". Figures "
(:ref "fig:translate-by-index-source")
" and "
(:ref "fig:translate-by-index")
" show the equivalent of our positioned-by-index example, but
with all the positioning done relative to the parent's center."
((:rendered-figure :caption "Translated by Index"
:object "translate-by-index"))))
((:subsection :title "Display Controls")
(:p "It is possible to specify particular default display
characteristics"
(:footnote "In addition to display-controls attached to a geometric entity
itself, GDL also supports the concept of "
(:emph "lenses")
", which capture the program code used to output a
particular class of entities (e.g. "
(:texttt "box")
" in a particular output format (e.g. "
(:texttt "pdf")
". for objects in GDL, such as: "
(:ul (:li "color")
(:li "line-thickness (for line-based output formats like PDF)")
(:li "transparency (for shaded graphics outputs like X3D)"))
)
(:p "The most common display-control is probably "
(:texttt ":color")
". Color in GDL can be specified in one of three formats:"
((:image-figure :image-file "color-map.png"
:caption "Color Map (assembled by Andrew
Wolven from standard X Window colors)"
:width "4in" :label "fig:color-map"))
((:list :style :enumerate)
(:item "By name. The names can be seen at the URL "
(:texttt "http://localhost:9000/color-map")
" as seen in Figure "
(:ref "fig:color-map"))
(:item "By hexadecimal Red-Green-Blue values, in the form of
a string beginning with the ``#'' character. Each two-digit
hex number represents a component of Red, Green, or Blue (to
make this easy to remember, use the mnemonic ``Roy G. Biv''
from the rainbow colors). For example, "
(:texttt "#000000")
" represents pure Black, and "
(:texttt "#FFFFFF")
" represents pure White. "
(:texttt "#FF0000")
" would be pure Red, "
(:texttt "#00FF00")
" would be pure Green, and "
(:texttt "#FF00FF")
" would be Purple (a mix of Red and Blue). Note that this
is also a standard for HTML and the World Wide Web.")
(:item "By a list of three decimal numbers between 0.0 and
1.0, again representing values for Red, Green, and Blue. For example, "
(:texttt "(1.0 1.0 1.0)")
" would be pure White, and "
(:texttt "(0.0 0.0 0.0)")
" would be pure Black."))
" The "
(:texttt "display-controls")
" is an optional input-slot for any geometric entity in GDL,
and is expected to be a "
(:emph "Property List")
" containing alternating keywords and values. Common keywords for the "
(:texttt "display-controls")
", corresponding to the display characteristics listed above, are: "
(:ul (:li (:texttt ":color"))
(:li (:texttt ":line-thickness"))
(:li (:texttt ":transparency")))
" Figures "
(:ref "fig:display-color")
" and "
(:ref "fig:display-color-source")
" demonstrate the use of the "
(:texttt ":color")
" keyword in the "
(:texttt "display-controls")
" for our positioned boxes example.")
((:rendered-figure :caption "Color controlled by display-controls"
:object "display-color"))
)
((:subsection :title "Orientation and the Alignment function")
(:p "Orientations in GDL are specified using a 3x3 orientation
matrix. The simplest way to compute an orientation matrix is to use
the use the "
(:texttt "alignment")
" function. The "
(:texttt "alignment")
" function accepts up to three direction keywords, and
corresponding vectors to which these directions should be aligned. For
example, to obtain an orientation matrix specifying that the Rear of a
reference box should be aligned with the vector "
(:texttt "#(1.0 0.0 0.0)")
", you could call "
(:verbatim
"(alignment :rear (make-vector 1 0 0))"))
((:rendered-figure :caption "Cylinder aligned vertically"
:object "vertical-cylinder"))
(:p "Generally, you will want the orientation of a child object to be
specified in a "
(:emph "relative")
" manner to that of the current (parent) object. The concept here is
similar to that for positioning with respect to "
(:texttt "(the center)")
". For relative orientation, you can utilize the various "
(:texttt "face-normal-vector")
"s of the parent object. For example, by default, cylinders are aligned with
their flat ends along the longitudinal (Y) axis. Figures "
(:ref "fig:vertical-cylinder-source")
" and "
(:ref "fig:vertical-cylinder")
" show the red cylinder which is turned to be
vertical (aligned to the Z axis), by aligning its "
(:texttt ":rear")
" face with "
(:texttt "(the (face-normal-vector :top))")
" of the parent base-object."))
((:rendered-figure :caption "Twisty Tower "
:object "tower"))
((:subsection :title "Rotating vectors with the rotate-vector-d function")
"In order to specify a vector which is not aligned exactly with
one of the major axes, you can use the "
(:texttt "rotate-vector-d")
" function to yield a new vector which is the result of
``rotating'' one vector about another vector. Figures "
(:ref "fig:tower-source")
" and "
(:ref "fig:tower")
" show a stack of boxes, where the rear face of each box is
rotated 2 degrees with respect to the box under it.")
((:subsection :title "Assemblies")
"Objects which you define with "
(:texttt "define-object")
" can be used no differently from the built-in primitives. This
underscores why it is important for the positioning and orientation
passed into a child object be "
(:emph "relative")
" to that present in the parent. Figures "
(:ref "fig:tower-assembly")
" and "
(:ref "fig:tower-assembly-source")
" show how several towers can be positioned side-by-side, while
maintaining consistent internal positioning and orientation. Figure "
(:ref "fig:tower-assembly-tasty")
" shows how the child towers form an "
(:emph "assembly hierarchy")
" of objects."
((:rendered-figure :caption "Tower Assembly"
:object "tower-assembly"))
((:image-figure :image-file "tower-assembly-tasty.png"
:caption "Tower Assembly as displayed in Tasty"
:width "4in" :height "3in"
:label "fig:tower-assembly-tasty")))
((:subsection :title "Mechanisms")
((:image-figure :image-file "4-bar-image.png"
:caption "Four-bar Link Mechanism"
:width "5in" :height "3in"
:label "fig:4bar-image"))
"GDL supports mechanisms without need for any special
features. By defining position and orientation of some objects to be
dependent on others, you can set up a mechanism. Figure "
(:ref "fig:4bar-image")
" shows a standard four-bar link mechanism which is defined in the code in
the file "
(:href "run:../examples/4-bar-assembly.gdl" "4-bar-assembly.gdl")
" (this is in the examples directory"
(:footnote "http://github.com/genworks/gendl/tree/master/documentation/tutorial/examples/")
" --- due to its length, the
source is not printed in the manual.")
((:subsection :title "Other Geometric Primitives")
"This chapter has focused primarily on the "
(:texttt "box")
" primitive, because every type of geometric primitive is based upon a "
(:emph "reference box")
". Other primitives have their own sets of input-slots, and their
own ways of being rendered in the various output formats. Basic
2D primitives include:"
(:ul (:li (:texttt "circle")
" described on page "
(:pageref "prim:circle"))
(:li (:texttt "line")
" described on page "
(:pageref "prim:line"))
(:li (:texttt "arc")
" described on page "
(:pageref "prim:arc"))
(:li (:texttt "ellipse")
" described on page "
(:pageref "prim:ellipse"))
(:li (:texttt "bezier-curve")
" described on page "
(:pageref "prim:bezier-curve")
(:footnote "The simple cubic bezier curve is supported
in the basic GDL and open-source Gendl. More
sophisticated NURBS-based curves and surfaces are
supported in the commercial GDL product when
accompanied with the SMLib geometry kernel.")))
"Basic 3D primitives include:"
(:ul (:li (:texttt "sphere")
" described on page "
(:pageref "prim:sphere"))
(:li (:texttt "cylinder")
" described on page "
(:pageref "prim:cylinder"))
(:li (:texttt "cone")
" described on page "
(:pageref "prim:cone"))
(:li (:texttt "global-polyline")
" described on page "
(:pageref "prim:global-polyline"))
(:li (:texttt "global-polygon-projection")
" described on page "
(:pageref "prim:global-polygon-projection"))
(:li (:texttt "global-filleted-polyline")
" described on page "
(:pageref "prim:global-polyline"))
(:li (:texttt "torus")
" described on page "
(:pageref "prim:torus"))
(:li (:texttt "route-pipe")
" described on page "
(:pageref "prim:route-pipe"))))))))
| 19,098 | Common Lisp | .lisp | 435 | 38.174713 | 132 | 0.656248 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 89a21c304d3d910357009dde441272d4d39861c63cbdc4f6e24cd0cdce59f00b | 36,086 | [
-1
] |
36,087 | understanding-common-lisp.gdl | lisp-mirror_gendl/documentation/tutorial/source/understanding-common-lisp.gdl | ;;
;; 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 :gendl-doc)
(defparameter *understanding-common-lisp*
`((:chapter :title "Understanding Common Lisp")
(:p "GDL is a superset of Common Lisp (CL) --- that is, all of
CL is available to you during development, and is available to your
applications at runtime (i.e. after they are deployed). The
lowest-level expressions in a GDL definition are CL ``symbolic
expressions,'' or ``S-expressions.'' This chapter will familiarize
you with CL S-expressions.")
((:section :title "S-expression Fundamentals")
(:p "S-expressions can be used in a similar manner to Formulas
in a Spreadsheet to establish the value of a particular "
(:emph "slot")
" (i.e. named data value) in an object. However, unlike in
a spreadsheet, these values are only computed on an as-needed
basis (i.e. ``on-demand''). You can also evaluate S-expressions at the
toplevel "
(:texttt "gdl-user" (:textgreater))
" prompt, and see the result immediately. In fact, this toplevel prompt is called a "
(:emph "read-eval-print")
" loop, because its purpose is to "
(:emph "read")
" each S-expression entered, "
(:emph "evaluate")
" the expression to yield a result (or "
(:emph "return-value")
"), and finally to "
(:emph "print")
" that result.")
(:p "CL S-expressions use a "
(:emph "prefix")
" notation, which means that they consist of either an "
(:emph "atom")
" (e.g. number, text string, symbol) or a "
(:emph "list")
" (one or more items enclosed by parentheses, where the
first item is taken as a symbol which names an
operator). Here is an example: "
(:verbatim "(+ 2 2)")
"This expression consists of the function named by the symbol "
(:texttt "+")
", followed by the numeric arguments "
(:texttt "2")
" and another "
(:texttt "2")
". As you may have suspected, when this expression is
evaluated it will return the value 4."
(:emph "Try it: ")
"try typing this expression at your command prompt, and see
the return-value being printed on the console. What is actually
occurring here? When CL is asked to evaluate an expression, it
processes the expression according to the following rules:")
(:p ((:list :style :itemize)
(:item "If the expression is an "
(:emph "atom")
" (e.g. a non-list datatype such as a number, text
string, or literal symbol), it simply returns itself as its evaluated
value. Examples: "
((:list :style :itemize)
(:item (:verbatim "gdl-user> 99
99"))
(:item (:verbatim "gdl-user> 99.9
99.9"))
(:item (:verbatim "gdl-user> 3/5
3/5"))
(:item (:verbatim "gdl-user> \"Bob\"
\"Bob\""))
(:item (:verbatim "gdl-user> \"Our golden rule is simplicity\"
\"Our golden rule is simplicity\""))
(:item (:verbatim "gdl-user> 'my-symbol
my-symbol")))
"Note that numbers are represented directly (with decimal
points and slashes for fractions allowed), strings are surrounded by
double-quotes, and literal symbols are introduced with a preceding
single-quote. Symbols are allowed to have dashes (``-'') and most
other special characters. By convention, the dash is used as a word
separator in CL symbols.")
(:item "If the expression is a "
(:emph "list")
" (i.e. is surrounded by parentheses), CL processes
the "
(:emph "first")
" element in this list as an "
(:emph "operator name")
", and the "
(:emph "rest")
" of the elements in the list represent the "
(:emph "arguments")
" to the operator. An operator can take zero or more
arguments, and can return zero or more return-values. Some operators
evaluate their arguments immediately and work directly on those
values (these are called "
(:emph "functions")
"). Other operators expand into other code. These are called "
(:emph "special operators")
" or "
(:emph "macros")
". Macros are what give Lisp (and CL in particular) its
special power. Here are some examples of functional S-expressions: "
((:list :style :itemize)
(:item (:verbatim "gdl-user> (expt 2 5)
32"))
(:item (:verbatim "gdl-user> (+ 2 5)
7"))
(:item (:verbatim "gdl-user> (+ 2)
2"))
(:item (:verbatim "gdl-user> (+ (+ 2 2) (+ 3 3 ))
10")))))))
((:section :title "Fundamental CL Data Types")
(:p "As has been noted, Common Lisp natively supports many data
types"
(:footnote "See http://en.wikipedia.org/wiki/Data_type for
a more detailed discussion of what is meant by ``data types'' in this
context.")
" common to other languages, such as numbers and text strings. CL
also contains several "
(:emph "compound")
" data types such as lists, arrays, and hash tables. CL
contains "
(:emph "symbols")
" as well, which typically are used as names for other data elements.")
(:p "Regarding data types, CL follows a system called dynamic
typing. Basically this means that values have type, but variables do
not necessarily have type, and typically variables are not
``pre-declared'' to be of a particular type. For example, a
variable (or slot name in GDL) called "
(:texttt "length")
" could contain a value "
(:texttt "42")
" (an integer), "
(:texttt "42.43")
" (a floating-point number), "
(:texttt "3/16")
" (a rational number), or even "
(:texttt ":long")
" (a descriptive keyword symbol).")
((:subsection :title "Numbers")
(:p "As observed, numbers in CL are a native data type which
simply evaluate to themselves when entered at the toplevel or included
in an expression.")
(:p "Numbers in CL form a hierarchy of types, which includes Integers,
Ratios, Floating Point, and Complex numbers. For many purposes, you
only need to think of a value as a ``number'' without getting any more
specific than that. Most arithmetic operations, such as "
(:texttt "+")
", "
(:texttt "-")
", "
(:texttt "*")
", "
(:texttt "/")
" etc, will automaticaly do any necessary type-coercion on their
arguments and will return a number of the appropriate type.
CL supports a full range of floating-point decimal numbers, as well as
true Ratios, which means that, for example, "
(:texttt "1/3")
" is a true one-third, not "
(:texttt "0.333333333")
" rounded off at some arbitrary precision short of
infinity."))
((:subsection :title "Strings")
(:p "Strings are actually a specialized kind of
array, namely a one-dimensional array (vector) made up of text
characters. These characters can be letters, numbers, or punctuation,
and in some cases can include characters from international character
sets (e.g. Unicode or UTF-8) such as Chinese Hanzi or Japanese
Kanji. The string delimiter in CL is the double-quote character.")
(:p "Text strings in CL are a native data type which simply
evaluate to themselves when included in an expression.")
(:p "A common way to produce a string in CL is with the "
(:texttt "format")
" function. Although the "
(:texttt "format")
" function can be used to send output to any kind of destination, or "
(:emph "stream")
", it will simply yield a string if you specify "
(:texttt "nil")
" for the stream. Example: "
(:small
(:verbatim "
gdl-user> (format nil \"The time is: ~a\" (get-universal-time))
\"The time is: 3564156603\"
gdl-user> (format nil \"The time is: ~a\" (iso-8601-date (get-universal-time)))
\"The time is: 2012-12-10\"
gdl-user> (format nil \"The time is: ~a\" (iso-8601-date (get-universal-time) :include-time? t))
\"The time is: 2012-12-10T14:30:17\"")))
(:p "As the above example demonstrates, "
(:texttt "format")
" takes a "
(:emph "stream designator")
" or "
(:texttt "nil")
" as its first argument, then a "
(:emph "format-string")
", then enough arguments to match the "
(:emph "format directives")
" in the format-string. Format directives begin with the
tilde character (" (:texttt "~") "). The format-directive "
(:texttt "~a")
" indicates that the printed representation of the corresonding argument should simpy be
substituted into the format-string at the point where it occurs.")
(:p "We will cover more details on "
(:texttt "format")
" in a section on "
" Input/Output, but for now, a familiarity with the simple use of "
(:texttt "(format nil ...)")
" will be helpful for Chapter "
(:ref "chap:understandinggdl---coregdlsyntax")
"."))
((:subsection :title "Symbols")
(:p "Symbols are such an important data structure in CL that people
sometimes refer to CL as a ``Symbolic Computing Language.'' Symbols
are a type of CL object which provides your program with a built-in
capacity to store and retrieve values and functions, as well as being
useful in their own right. A symbol is most often known by its name
(actually a string), but in fact there is much more to a symbol than
its name. In addition to the name, symbols also contain a "
(:emph "function")
" slot, a "
(:emph "value")
" slot, and an open-ended "
(:emph "property-list")
" slot in which you can store an arbitrary number of named properties.")
(:p "For a named function such as "
(:texttt "+")
" the function-slot contains the actual function
object for performing numeric addition. The value-slot of a symbol can
contain any value, allowing the symbol to act as a global variable, or "
(:emph "parameter")
". And the property-list, also known as the "
(:emph "plist")
" slot, can contain an arbitrary amount of information.")
(:p "This separation of the symbol data structure into "
(:emph "function")
", "
(:emph "value")
", and "
(:emph "plist")
" slots is one fundamental distinction between Common Lisp
and most other Lisp dialects. Most other dialects allow only one (1)
``thing'' to be stored in the symbol data structure, other than its
name (e.g. either a function or a value, but not both at the same
time). Because Common Lisp does not impose this restriction it is not
necessary to contrive names, for example for your variables, to avoid
conflicting with existing ``reserved words'' in the system. For
example, "
(:texttt "list")
" is the name of a built-in function in CL, but you may
freely use "
(:texttt "list")
" as a variable name as well. There is no need to
contrive arbitrary abbreviations such as "
(:texttt "lst")
".")
(:p "How symbols are evaluated depends on where they are
located in an expression. As we have seen, if a "
(:emph "symbol")
" appears first in a list expression, as with the "
(:texttt "+")
" in "
(:texttt "(+ 2 2)")
", the symbol is evaluated for its function slot. If the
first element of an expression indeed has an identified "
(:emph "function")
" in its function slot, then any
subsequent symbol in the expression is taken as a variable, and it is evaluated
for its global or local value, depending on its scope (more on variables and
scope later).")
(:p "As noted in Section 3.1.3, if you want a literal symbol itself, one
way to achieve this is to ``quote'' the symbol name:"
(:verbatim "'a"))
(:p "Another way is for the symbol to appear within a quoted list expression, for example:"
(:verbatim "'(a b c)")
" or "
(:verbatim "'(a (b c) d)"))
(:p "Note that the quote ("
(:texttt "'")
") applies across everything in the list expression, including any sub- expressions."))
((:subsection :title "List Basics")
(:p "Lisp derives its name from its strong support for the
list data structure. The list concept is important to Common Lisp (CL)
for more than this reason alone --- most notably, lists are important
because "
(:emph "all CL programs are themselves lists."))
(:p " Having the list as a native data structure, as well as the form of all
programs, means that it is straightforward for CL programs to compute
and generate other CL programs. Likewise, CL programs can read and
manipulate other CL programs in a natural manner. This cannot be said
of most other languages, and is one of the primary distinguishing
characteristics of Lisp as a language.")
(:p "Textually, a "
(:emph "list")
" is defined as zero or more items surrounded by
parentheses. The items can be objects of any valid CL data types, such
as numbers, strings, symbols, lists, or other kinds of
objects. According to standard evaluation rules, you must quote a
literal list to evaluate it as such, or CL will assume you are calling
a "
(:emph "function")
". Now look at the following list:"
(:verbatim "(defun hello () (write-string \"Hello, World!\"))")
"This list also happens to be a valid CL program (function definition,
in this case). Don't concern yourself about analyzing the function definition
right now, but do take a few moments to convince yourself that it
meets the requirements for a list.")
(:p "What are the types of the elements in this list?"
(:footnote "Answer: symbol, symbol, (empty) list, list with symbol and string."))
(:p "In addition to using the quote (') to produce a literal list, another
way to produce a list is to call the function "
(:texttt "list")
". The function "
(:texttt "list")
" takes any number of arguments, and returns a list made up
from the result of evaluating each argument. As with all functions,
the arguments to the "
(:texttt "list")
" function get evaluated, from left to right, before being
processed by the function. For example:"
(:verbatim "(list 'a 'b (+ 2 2))")
"will return the list"
(:verbatim "(a b 4)")
"The two quoted symbols evaluate to symbols, and the function
call "
(:texttt "(+ 2 2)")
" evaluates to the number 4."))
((:subsection :title "The List as a Data Structure")
"In this section we will discuss a few of the fundamental native
CL operators for manipulating lists as data structures. These include
operators for doing things such as:"
((:list :style :enumerate)
(:item "finding the length of a list;")
(:item "accessing particular members of a list;")
(:item "appending multiple lists together to make a new list."))
((:subsubsection :title "Finding the Length of a List")
"The function "
(:texttt "length")
" will return the length of any type of sequence, including a list:"
(:verbatim
"gdl-user> (length '(a b c d e f g h i j)
10
gdl-user> (length nil)
0")
"Note that "
(:texttt "nil")
" qualifies as a list (albeit the empty list), so taking its length yields the integer "
(:texttt "0")
"."))
((:subsubsection :title "Accessing the Elements of a List")
"Common Lisp defines the accessor functions "
(:texttt "first")
" through "
(:texttt "tenth")
" as a means of accessing the first ten elements in a list:"
(:verbatim "
gdl-user> (first '(a b c))
a
gdl-user> (second '(a b c))
b
gdl-user> (third '(a b c))
c")
"For accessing elements in an arbitrary position in the list, you can use the function nth,
which takes an integer and a list as its two arguments:"
(:verbatim "
gdl-user> (nth 0 '(a b c))
a
gdl-user> (nth 1 '(a b c))
b
gdl-user> (nth 2 '(a b c))
c")
"Note that nth starts its indexing at zero (0), so "
(:texttt "(nth 0 ...)")
" is equivalent to "
(:texttt "(first ...)")
"and "
(:texttt "(nth 1 ...)")
" is equivalent to "
(:texttt "(second ...)")
", etc.")
((:subsubsection :title "Using a List to Store and Retrieve Named Values")
"Lists can also be used to store and retrieve named values. When a list is used in this way,
it is called a "
(:emph "plist")
". Plists contain pairs of elements, where each pair consists of a "
(:emph "key")
" and some "
(:emph "value")
". The key is typically an actual keyword symbol --- that is,
a symbol preceded by a colon (:). The value can be any value, such as
a number, a string, or even a GDL object representing something
complex such as an aircraft.
A plist can be constructed in the same manner as any list, e.g. with the "
(:texttt "list")
" operator:"
(:verbatim "(list :a 10 :b 20 :c 30)")
"In order to access any element in this list, you can use the "
(:texttt "getf")
" operator. The "
(:texttt "getf")
" operator is specially intended for use with plists:"
(:verbatim "gdl-user> (getf (list :a 10 :b 20 :c 30) :b
20
gdl-user> (getf (list :a 10 :b 20 :c 30) :c
30")
" Common Lisp contains several other data structures for mapping keywords or numbers to values, such
as "
(:emph "arrays")
" and "
(:emph "hash tables")
". But for relatively short lists, and especially for rapid prototyping and testing work, plists
can be useful. Plists can also be written and read (i.e. saved and restored) to and from plain text files
in your filesystem, in a very natural way.")
((:subsubsection :title "Appending Lists")
"The function "
(:texttt "append")
" takes any number of lists, and returns a new list which results from
appending them together. Like many CL functions, append does not "
(:emph "side-effect")
". That is, it simply returns a new list as a return-value, but does not modify its
arguments in any way:"
(:verbatim "
gdl-user> (defparameter my-slides '(introduction welcome lists functions))
(introduction welcome lists functions)
gdl-user> (append my-slides '(numbers))
(introduction welcome lists functions numbers)
gdl-user> my-slides
(introduction welcome lists functions)")
"Note that the simple call to "
(:texttt "append")
" does not affect the variable "
(:texttt "my-slides")
". Later we will observe how one may alter the value of a
variable such as "
(:texttt "my-slides")
"."))
((:section :title "Summary")
"In this chapter we have presented enough basics of Lisp's
minimal syntax, and some particulars of Common Lisp, to enable you to
start with the Genworks GDL framework. In keeping with the
demand-driven philosophy of GDL, subsequent chapters will cover additional
CL material on an as-needed basis.")))
| 19,115 | Common Lisp | .lisp | 460 | 37.847826 | 105 | 0.692233 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | dc056e963bc43531143492ae898e1ad1fede14a2e9b92530424b98b7446f325e | 36,087 | [
-1
] |
36,088 | installation.lisp | lisp-mirror_gendl/documentation/tutorial/source/installation.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 :gendl-doc)
(defparameter *installation*
`((:chapter :title "Installation [GDL and Gendl]")
"Please follow Section "
(:ref "sec:installationofpre-packagedgdl")
" if your email address is registered with Genworks and you will
install a pre-packaged Genworks GDL distribution, including its own
Common Lisp engine. The foundation of Genworks GDL is also available
as open-source software through The Gendl Project"
(:footnote "http://github.com/genworks/gendl")
"; if you elect to use that version, then please refer to Section "
(:ref "sec:installationofopen-sourcegendl")
"."
((:section :title "Installation of pre-packaged GDL")
"This section will take you through the installation of
Genworks GDL from a prepackaged distribution with the Allegro CL or
LispWorks commercial Common Lisp engine and the Slime IDE (based on
Gnu Emacs)."
((:subsection :title "Download the Software and retrieve a license key")
((:list :style :enumerate)
(:item "Visit the Downloads section of the "
(:href "http://genworks.com" "Genworks Website") ";")
(:item "Enter your email address"
(:footnote "if your address is not on file, send mail to [email protected]")
";")
(:item "Download the latest Payload for Windows, Linux, or Mac;")
(:item "Click to receive the license key file by email.")))
((:subsection :title "Unpack the Distribution")
"Genworks GDL is currently distributed as a setup executable for Windows,
a ``dmg'' application bundle for Mac, and a self-contained zip file for Linux."
(:ul
(:item "Run the installation executable. Accept the defaults when prompted."
(:footnote "For Linux, you have to install emacs and ghostscript yourself. Please use your distribution's package manager to complete this installation."))
(:item "Copy the license key file as gdl.lic (for Trial,
Student, Professional editions), or devel.lic (for Enterprise edition) into the "
(:texttt "program/")
" directory within the "
(:texttt "gdl/gdl/program/")
" directory.")
(:item "Launch the application by finding the Genworks program group in the Start menu (Windows), or by double-clicking the application icon (Mac), or by running the "
(:texttt "run-gdl")
" script (Linux)."))))
((:section :title "Installation of open-source Gendl")
"This section is only germane if you have not received a
pre-packaged Gendl or Genworks GDL distribution with its own Common
Lisp engine. If you have received a pre-packaged Gendl distribution
then you may skip this section. In case you want to use the
open-source Gendl, you will use your own Common Lisp installation and
obtain Gendl (Genworks-GDL) using a powerful and convenient CL
package/library manager called "
(:emph "Quicklisp") "."
((:subsection :title "Install and Configure your Common Lisp environment")
"Gendl is currently tested to build on the following Common Lisp engines:"
((:list :style :itemize)
(:item "Allegro CL (commercial product from Franz Inc, free Express Edition available)")
(:item "LispWorks (commercial product from LispWorks Ltd, free Personal Edition available)")
(:item "Clozure CL (free CL engine from Clozure Associates, free for all use)")
(:item "Steel Bank Common Lisp (SBCL) (free open-source project with permissive license)"))
"Please refer to the documentation for each of these systems
for full information on installing and configuring the
environment. Typically this will include a text editor, either Gnu
Emacs with Superior Lisp Interaction Mode for Emacs (Slime), or a
built-in text editing and development environment which comes with the
Common Lisp system.
A convenient way to set up Emacs with Slime is to use the "
(:href "http://github.com/quicklisp/quicklisp-slime-helper" "Quicklisp-slime-helper")
".")
((:subsection :title "Load and Configure Quicklisp")
"Quicklisp is the defacto standard library manager for Common
Lisp."
((:list :style :itemize)
(:item "Visit the " (:href "http://quicklisp.org" "Quicklisp website"))
(:item "Follow the instructions there to download the "
(:texttt "quicklisp.lisp")
" bootstrap file and load it to set up your Quicklisp environment.")))
((:subsection :title "Load and Start Gendl")
"invoke the following commands at the Common Lisp toplevel ``repl'' prompt:"
(:ol
(:li (:texttt "(ql:quickload :gendl)"))
(:li (:texttt "(gendl:start-gendl!)")))))
((:section :title "System Testing")
((:subsection :title "Basic Sanity Test")
"You may test your installation using the following
checklist. These tests are optional. You may perform some or all of
them in order to ensure that your Gendl is installed correctly and
running smoothly. In your Web Browser (e.g. Google Chrome, Firefox,
Safari, Opera, Internet Explorer), perform the following steps:"
((:list :style :enumerate)
(:item "visit http://localhost:9000/tasty.")
(:item "accept default robot:assembly.")
(:item "Select ``Add Leaves'' from the Tree menu.")
(:item "Click on the top node in the tree.")
(:item "Observe the wireframe graphics for the robot as shown in "
(:ref "fig:tasty-robot")
".")
((:image-figure :image-file "tasty-robot.png"
:caption "Robot displayed in Tasty"
:height "3in" :width "3in"
:label "fig:tasty-robot"))
((:image-figure :image-file "tasty-robot-x3dom.png"
:caption "Robot x3dom"
:height "3in" :width "3in"
:label "fig:tasty-robot-x3dom"))
(:item "Click on the robot to zoom in.")
(:item "Select ``Clear View!'' from the View menu.")
(:item "Select ``X3DOM'' from the View menu.")
(:item "Click on the top node in the tree.")
(:item "``Refresh'' or ``Reload'' your browser window (may not be necessary).")
(:item "If your browser supports WebGL, you will see the robot in shaded dynamic view as shown in Figure"
(:ref "fig:tasty-robot-x3dom")
".")
(:item "Select ``PNG'' from the View menu. You will see the
wireframe view of the robot as a PNG image.")
(:item "Select ``X3D'' from the View menu. If your browser
has an X3D plugin installed (e.g. BS Contact), you will see the robot
in a shaded dynamic view.")))
((:subsection :title "Full Regression Test")
(:index "regression tests")
"The following commands will invoke a full regression test,
including a test of the Surface and Solids primitives provided by the
SMLib geometry kernel. Note that the SMLib geometry kernel is only
available with proprietary Genworks GDL licenses --- therefore, if you
have open-source Gendl or a lite Trial version of Genworks GDL, these
regression tests will not all function.
In Emacs at the "
;;(:texttt "gdl-user>")
(:texttt "gdl-user")
" prompt in the "
(:texttt "*slime-repl...*") " buffer, type the following commands:"
((:list :style :enumerate)
(:item (:texttt "(ql:quickload :regression)"))
(:item (:texttt "(gdl-lift-utils::define-regression-tests)"))
(:item (:texttt "(gdl-lift-utils::run-regression-tests-pass-fail)"))
(:item (:texttt "(pprint gdl-lift-utils::*regression-test-report*)")))))
((:section :title "Getting Help and Support")
"If you encounter unexplained errors in the installation and
startup process, please contact the following resources:"
((:list :style :enumerate)
(:item "Make a posting to the "
(:href "http://groups.google.com/group/genworks" "Genworks Google Group"))
(:item "Join the #gendl IRC (Internet Relay Chat) channel on
irc.freenode.net and discuss issues there.")
(:item "For exclusively Common Lisp issues, join the #lisp
IRC (Internet Relay Chat) channel on irc.freenode.net and
discuss issues there.")
(:item "Also for Common Lisp issues, follow the comp.lang.lisp
Usenet group.")
(:item "If you are a supported Genworks customer, send email to "
(:href "mailto:[email protected]" "[email protected]"))
(:item "If you are not a supported Genworks customer but you want to report an apparent bug or have other suggestions or inquiries, you may also send email to "
(:href "mailto:[email protected]" "[email protected]")
", but as a non-customer please understand that Genworks
cannot guarantee a response or a particular time frame for a
response. Also note that we are not able to offer guaranteed
support for Trial and Student licenses ")))))
| 9,311 | Common Lisp | .lisp | 175 | 49.542857 | 169 | 0.731607 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | dc4807a18f5ab6eac7514c8a88ea04cf6caba0690a50443f66e1b79d00c53eb9 | 36,088 | [
-1
] |
36,089 | advanced-common-lisp.gdl | lisp-mirror_gendl/documentation/tutorial/source/advanced-common-lisp.gdl | ;;
;; 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 :gendl-doc)
(defparameter *advanced-common-lisp*
`((:chapter :title "More Common Lisp for GDL")
))
| 963 | Common Lisp | .lisp | 24 | 38.75 | 70 | 0.75641 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | f165194a86ed14b020d010b433d1311a3cbaee1c0a9f1da36287f2b508b359a2 | 36,089 | [
-1
] |
36,090 | bibliography.lisp | lisp-mirror_gendl/documentation/tutorial/source/bibliography.lisp | (in-package :gendl-doc)
(defparameter *bibliography*
"\\begin{thebibliography}{1}
\\bibitem{LaRocca} G. LaRocca \\emph{Knowledge based engineering: Between AI
and CAD. Review of a language based technology to support engineering design}
Advanced Engineering Informatics 26 (2012) 159-179, Elsevier.
\\end{thebibliography}
")
| 331 | Common Lisp | .lisp | 8 | 39.625 | 78 | 0.79375 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a8918a035d31e0a846d49dcb0674652bfe8d874b5e50dbd692feda7eeadcbbaf | 36,090 | [
-1
] |
36,091 | parameters.lisp | lisp-mirror_gendl/documentation/tutorial/source/parameters.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 :gendl-doc)
(defparameter *system-home*
(translate-logical-pathname
(merge-pathnames "../" (make-pathname :name nil :type nil :defaults #.(or *compile-file-pathname* *load-pathname*)))))
| 1,054 | Common Lisp | .lisp | 24 | 42.416667 | 121 | 0.752678 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | e637f908b54fc26a3f750813735fabdf9ffed3937fe6cfd5a78cdcdd0df5fc71 | 36,091 | [
-1
] |
36,092 | upgrade-notes.lisp | lisp-mirror_gendl/documentation/tutorial/source/upgrade-notes.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 :gendl-doc)
(defparameter *upgrade-notes*
`((:chapter* :title "Upgrade Notes")
"GDL 1580 marked the end of a major branch of GDL development,
and 1581 was an upgraded new version, which has now been supplanted by
1592.
This addendum lists the typical modifications you will want to
consider for upgrading from versions of GDL prior to 1582."
((:list :style :itemize)
(:item "(make-gdl-app ..) is now available for 1582. We have
made available an Enterprise Edition of 1582 which includes the
make-gdl-app function, which creates Runtime applications without the
compiler or GDL development facilities. If you are an Enterprise
licensee, and are ready to release Runtime applications on 1582, and
you have not received information on the Enterprise Edition, please
contact [email protected]")
(:item "(register-asdf-systems) and the "
(:texttt "\"3rdpty/\"")
" directory are no longer needed or available. Instead, we depend on the Quicklisp
system. Details of Quicklisp are available at "
(:texttt "http://www.quicklisp.org")
". See Section "
(:ref "subsec:compilingandloadingasystem")
" for information about how to use Quicklisp with GDL.")
(:item "There is a system-wide "
(:texttt "gdlinit.cl")
" in the application directory, and depending on the
particular release you have, this may have some default
information which ships with GDL. There is a personal "
(:texttt "gdlinit.cl")
" in home directory, which you should modify if you want to
customize anything.")
(:item "Slime debugging is different from the ELI emacs debugger. The main thing to know is
to press ``a'' or ``q'' to pop out of the current error. Full documentation for the Slime debug mode
is available with the "
(:href "http://common-lisp.net/project/slime/doc/html/Debugger.html" "Slime documentation")
".")
(:item "color-themes -- GDL now ships with the Emacs
color-theme package. You can select a different color theme with "
(:texttt "M-x color-theme-select")
". Press [Enter] or middle-mouse on a color theme to apply it.")
(:item "GDL files can now end with "
(:texttt ".lisp")
" or "
(:texttt ".gdl")
". The new "
(:texttt ".gdl")
" extension will work for emacs Lisp mode and will work with
cl-lite, ASDF, and Quicklisp for including source files in application systems. We recommend migrating
to the new "
(:texttt ".gdl")
" extension for files containing "
(:texttt "define-object")
", "
(:texttt "define-format")
", and "
(:texttt "define-lens")
" forms, and any other future toplevel defining forms introduced by GDL, in order to distinguish
from files containing raw Common Lisp code.")
(:item "in gdlAjax, HTML for a sheet-section is given in the slot called "
(:texttt "inner-html")
" instead of "
(:texttt "main-view")
". This name change was made to clarify what exactly is
expected in this slot -- it is the innerHTML of the page
division represented by the current sheet-section. If you
want to make your code back-compatible with GDL 1580, you can
use the following form in place of old occurences of "
(:texttt "main-view")
": "
(:verbatim "... #+allegro-v8.1 main-view #-allegro-v8.1 inner-html ..."))
(:item "(update-gdl ..) is not available for 1592. Instead
of updating incrementally with patches, the intention starting with
GDL 1592 is for full GDL releases to be made available approximately
monthly. Less frequent Long Term Maintenance (``LTS'') releases will
also be made available along with a new simpler maintenance patch
system."))))
| 4,539 | Common Lisp | .lisp | 97 | 43.340206 | 104 | 0.73382 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 9eb98a2c2c66766695fab89f4ad220f9f6e19f45acd1330e35bd2885882b4d3b | 36,092 | [
-1
] |
36,093 | mybox.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/examples/source/mybox.lisp | (in-package :gdl-surf-user)
(define-object mybox (box-solid)
:computed-slots
((length 20 :settable)
(width (progn (format t "Hey Now~%") (twice (the length))))
(height 40)
(display-controls (list :color :blue :transparency 0.3))
))
| 266 | Common Lisp | .lisp | 8 | 28 | 62 | 0.66805 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a2c800fb30a84f76b23fd093b4f977558ccb793eb1b25409255b35e7078af03f | 36,093 | [
-1
] |
36,094 | primitives.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/examples/solids/source/primitives.lisp | (in-package :gdl-surf-user)
(define-object section-curve (base-object)
:objects
((surface :type 'surf::test-b-spline-surface)
(intersection-curve :type 'planar-section-curve
:plane-normal (the (face-normal-vector :top))
:plane-point (translate (the center)
:up 2))))
(define-object test-box (box-solid)
:input-slots
((length 10)
(width 10)
(height 20)
(display-controls (list :color :green
:transparency 0.5))
)
:hidden-objects
((hole :type 'cylinder-solid
:length (* (the length) 1.1)
:radius (half (half (the width)))))
:objects
(
(subtraction :type 'subtracted-solid
:brep self
:other-brep (the hole))
(vertex-spheres :type 'sphere
:display-controls (list :color :red)
:sequence (:size (the subtraction vertices
number-of-elements))
:center (the subtraction
(vertices (the-child index))
center)
:radius (/ (the length) 50))))
| 977 | Common Lisp | .lisp | 33 | 24.121212 | 54 | 0.65 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | f620db73caa3afc82f92afa049fdcbec810122bfa0afcdd9027da4d08d815377 | 36,094 | [
-1
] |
36,095 | web-page.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/examples/solids/source/web-page.lisp | (in-package :gwl-user)
(define-object surface-ui (base-html-graphics-sheet)
:hidden-objects
((b-spline-surface :type 'surf::test-b-spline-surface)
(view-object :type 'web-drawing
:objects (list (the b-spline-surface))
:projection-vector (getf *standard-views* :trimetric)
)))
(define-view (html-format surface-ui)()
:output-functions
((main-sheet
()
(html (:html (:head (:title "Example of a Sectioned Surface"))
(:body (:p (the write-development-links))
(:h2 "Example of a Sectioned Surface")
(:p (:table
(:tr
((:td :bgcolor :yellow) "Surface Area")
(:td (:princ (number-round
(the b-spline-surface area) 3))))
))
(with-html-form ()
(:p (the write-geometry)))))))))
| 791 | Common Lisp | .lisp | 23 | 28 | 66 | 0.631507 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 9dfb9bcd5a080db80e8f57243248a706131f6b44aa729be52efd4f4b4c278a86 | 36,095 | [
-1
] |
36,096 | assembly.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/examples/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))))))
: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)))
: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))
(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-view (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"))))))))
| 4,294 | Common Lisp | .lisp | 109 | 32.862385 | 96 | 0.61488 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | b8f13157e57e3d0895bab9901a9be2a3c088d6c39ed908d7d2e39b46b3e34f06 | 36,096 | [
-1
] |
36,097 | building.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/examples/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.
;;
(define-object building (box)
:input-slots (section proximity-rules)
:computed-slots
(;;
;; catch-all color for any non-specific buildings or building sub-types
;; with no color specified.
;;
(color :black)
(display-controls (list :color (the color)
(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)))
(define-object proximity-rule ()
:input-slots (current-building neighbors target-type distance)
: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))))
;;
;;
;; FLAG -- fill in this value.
;;
;; 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 nil)))
| 3,424 | Common Lisp | .lisp | 85 | 35.341176 | 87 | 0.690046 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 28c2f8a7544593298d3f11a84efa9c948b7af915e5af0ce5fbdcd732fae93fb0 | 36,097 | [
-1
] |
36,098 | grid-section.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/examples/city/source/grid-section.lisp | (in-package :city)
(define-object grid-section (box)
:input-slots (buildings-list)
:computed-slots
((height 0)
(display-controls (list :color :periwinkle))
(potential-neighbor-index-pairs
(list (list (1- (first (the index))) (second (the index)))
(list (1- (first (the index))) (1- (second (the index))))
(list (first (the index)) (1- (second (the index))))
(list (1+ (first (the index))) (second (the index)))
(list (1+ (first (the index))) (1+ (second (the index))))
(list (first (the index)) (1+ (second (the index))))))
(valid-neighbor-index-pairs
(let ((number-of-elements (plist-values (the aggregate number-of-elements))))
(remove-if #'(lambda(pair)
(or (minusp (first pair)) (minusp (second pair))
(= (first pair) (first number-of-elements))
(= (second pair) (second number-of-elements))) )
(the potential-neighbor-index-pairs))))
(neighbors (cons self (mapcar #'(lambda(pair)
(the (sections (first pair) (second pair))))
(the valid-neighbor-index-pairs))))
(nearby-buildings
(apply #'append
(mapcar #'(lambda(section) (the-object section buildings-list))
(the neighbors))))))
| 1,224 | Common Lisp | .lisp | 27 | 39.185185 | 81 | 0.639033 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 0b8711bfae26a169deb03bdd1980e0324e12669af6ae94fef53091cd5f5a81ed | 36,098 | [
-1
] |
36,099 | t-support.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/examples/iidl/source/t-support.lisp | (in-package :gdl-user)
(define-object t-support-1 (box)
:input-slots
(cost-per-inch
(length 120)
)
:computed-slots
((height (/ (the width) 2))
(width 12)
(support-thickness 2)
(cost (* (the length) (the cost-per-inch))))
:objects
((vertical-support :type 'box
:center (translate (the center)
:down
(half (the-child height)))
:width (the support-thickness)
:height (the height)
:length (the length))
(horizontal-support :type 'box
:center (translate (the center)
:up
(half (the-child height)))
:width (the width)
:length (the length)
:height (the support-thickness))))
| 720 | Common Lisp | .lisp | 26 | 20.846154 | 47 | 0.600904 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 530bc4f9b0b5c0c8ca35c789812408d1139921354a1de753754a71a3618d772e | 36,099 | [
-1
] |
36,100 | table.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/examples/iidl/source/table.lisp | (in-package :gdl-user)
(define-object table (box)
:input-slots
((leg-type 't-support-1)
(length 50)
(width 70)
(height 20 :settable)
(top-thickness 1/2)
(number 2 :settable)
)
:objects
((table-top :type 'box
:length (the length)
:width (the width)
:height (the top-thickness))
(legs :type (the leg-type)
:length (the height)
:width 2
:height 3
:orientation (alignment (ecase (first (the-child index))
(1 :bottom)
(0 :top))
(the (face-normal-vector :rear)))
:center (translate (the center)
(ecase (second (the-child index))
(0 :right)
(1 :left))
(- (half (the width)) (half (the-child width)))
(ecase (first (the-child index))
(0 :rear)
(1 :front))
(- (half (the length))
(half (the-child height)))
:down (+ (half (the top-thickness))
(half (the-child length))))
:sequence (:matrix :longitudinal (the number) :lateral (the number)))))
| 1,058 | Common Lisp | .lisp | 36 | 22.277778 | 73 | 0.575385 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 9cc1033f48faa2e6a93862b4cdfc874ac3f9586a0b3b2248e45942b5e39978ca | 36,100 | [
-1
] |
36,101 | simple-linkage.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/examples/ackermann/source/simple-linkage.lisp | (in-package :ackermann)
(define-object simple-linkage (box)
:input-slots
(tie-rod-length
(kingpin-center (make-point 0 0 0))
(kingpin-radius 15)
(kingpin-inclination 10)
(kingpin-length 100)
(tie-rod-arm-length 300)
(tie-rod-arm-width 30)
(tie-rod-arm-height 30)
(tie-rod-arm-offset 50)
(current-rotation-angle 0)
(side :left)
(height (* (the kingpin-length) 1.25))
(width (* (the kingpin-diameter) 1.25))
(length (the width)))
:computed-slots
((kingpin-diameter (twice (the kingpin-radius)))
(kingpin-axis (the kingpin direction-vector))
(tie-rod-arm-ball-center (the tie-rod-arm ball-center))
(tie-rod-arm-vector (subtract-vectors (the tie-rod-arm-ball-center) (the tie-rod-arm-pivot-point)))
(straight-ahead-tie-rod-arm-ball-center (the straight-ahead-tie-rod-arm ball-center))
(tie-rod-arm-pivot-point (inter-line-plane
(the kingpin center) (the kingpin-axis)
(the straight-ahead-tie-rod-arm-ball-center) (the kingpin-axis)))
(straight-ahead-tie-rod-arm-vector (subtract-vectors (the straight-ahead-tie-rod-arm-ball-center)
(the tie-rod-arm-pivot-point))))
:objects
((kingpin :type 'cylinder
:radius (the kingpin-radius)
:center (the kingpin-center)
:length (the kingpin-length)
:orientation (alignment :front
(rotate-vector-d (the (face-normal-vector :top)) (the kingpin-inclination)
(the (face-normal-vector (the side))))))
(tie-rod-arm :type 'tie-rod-arm
:kingpin-center (the kingpin center)
:kingpin-axis (the kingpin-axis)
:front-vector (the (face-normal-vector :left))
:length (the tie-rod-arm-length)
:width (the tie-rod-arm-width)
:height (the tie-rod-arm-height)
:offset (the tie-rod-arm-offset)
:current-rotation-angle (the current-rotation-angle)))
:hidden-objects
((straight-ahead-tie-rod-arm :type 'tie-rod-arm
:kingpin-center (the kingpin center)
:kingpin-axis (the kingpin-axis)
:front-vector (the (face-normal-vector :left))
:length (the tie-rod-arm-length)
:width (the tie-rod-arm-width)
:height (the tie-rod-arm-height)
:offset (the tie-rod-arm-offset)
:current-rotation-angle 0)
(tie-rod-ball-socket-sphere :type 'sphere
:center (the tie-rod-arm ball-center)
:radius (the tie-rod-length))
(tie-rod-arm-ball-articulation-circle :type 'circle
:radius (half (the tie-rod-arm length))
:center (inter-line-plane (the kingpin center)
(the kingpin-axis)
(the straight-ahead-tie-rod-arm-ball-center)
(the kingpin-axis))
:orientation (alignment :top (the kingpin direction-vector)))))
| 2,722 | Common Lisp | .lisp | 65 | 35.907692 | 102 | 0.671828 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 294cf05d062d283038096b97e92ca930d3c449b91213cf11976bad798b3d6267 | 36,101 | [
-1
] |
36,102 | ackermann-assembly.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/examples/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. Enabled 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-spec (list :left 30)))
:computed-slots
((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 (ecase (first (the current-rotation-angle-spec))
(:left 0) (:right 1)))))
(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))
;;
;; FLAG -- compute this based on intersection of sphere and 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 kingpin-axis)
(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) (first (the current-rotation-angle-spec)))
(second (the current-rotation-angle-spec))
(the other-tie-rod-rotation)))))
| 2,676 | Common Lisp | .lisp | 60 | 39 | 98 | 0.693885 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 353e10acbc2031bba4756869fa3846bf4f1cc6ac7971c9cef21d903fb9cf74d1 | 36,102 | [
-1
] |
36,103 | tie-rod-arm.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/examples/ackermann/source/tie-rod-arm.lisp | (in-package :ackermann)
(define-object tie-rod-arm (box)
:input-slots
(kingpin-center
kingpin-axis
front-vector
offset
current-rotation-angle
(ball-radius 20))
:computed-slots
((center (translate-along-vector (the kingpin-center) (the kingpin-axis) (the offset)))
(orientation (alignment :top (the kingpin-axis) :front
(rotate-vector-d (the front-vector) (the current-rotation-angle)
(the kingpin-axis))))
(ball-center (the (face-center :rear))))
:objects
((ball :type 'sphere
:radius (the ball-radius)
:center (the ball-center))
(pipe :type 'c-cylinder
:radius (half (the width))
:start (the center)
:end (the ball center))))
| 693 | Common Lisp | .lisp | 23 | 26.26087 | 89 | 0.690691 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 76d5457acfa8ff1c01dabc6f5625aa8898baceb93a53aad4a89f5a8b0c32169a | 36,103 | [
-1
] |
36,104 | hairy.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/examples/source/hairy.lisp | (in-package :training-g102)
(define-object hairy-calc ()
:input-slots (num)
:computed-slots
((a (twice (the num)))
(b (+ (the a) 1000))
(c (if (> (the b) 5000)
(+ (the b) (* (the b) 0.05))
(the b)))
(d (/ (the c) 24))))
(define-object silly-object () :computed-slots ((a 50) (b (expt (the a) 2))))
(define-object silly-object-2 () :input-slots (a) :computed-slots ((b (expt (the a) 2))))
(define-object hello-there ()
:input-slots (name fancy?)
:computed-slots ((greeting (format nil "Hello ~a~a~a" (if (the fancy?) "there " "") (the name)
(if (the fancy?) ", How Are You?" "")))))
(define-object silly-adder ()
:input-slots (a b)
:computed-slots ((sum (+ (the a) (the b)))))
(defun compute-sum (a b)
(let ((self (make-object 'silly-adder :a a :b b)))
(the sum)))
(defun silly-adder (a b)
(+ a b))
(define-object city (box)
:input-slots
((length 10)
(width 10)
(height 0.25)
(max-allowed-daily-water-usage 5000)
(building-1-data '(:type bank :height 30 :width 70 :length 50))
(building-2-data '(:type hotel :height 100 :width 40 :length 30)))
:computed-slots
((total-daily-water-usage
(+ (the building-1 daily-water-usage)
(the building-2 daily-water-usage)))
(too-much-water-usage?
(> (the total-daily-water-usage) (the max-allowed-daily-water-usage))))
:objects
((building-1 :type (getf (the building-1-data) :type)
:height (getf (the building-1-data) :height)
:width (getf (the building-1-data) :width)
:length (getf (the building-1-data) :length))
(building-2 :type (getf (the building-2-data) :type)
:height (getf (the building-2-data) :height)
:width (getf (the building-2-data) :width)
:length (getf (the building-2-data) :length))))
(define-object city-2 (box)
:input-slots
((length 10)
(width 10)
(height 0.25)
(max-allowed-daily-water-usage 5000)
(building-1-data '(:type bank :height 30 :width 70 :length 50))
(building-2-data '(:type hotel :height 100 :width 40 :length 30)))
:computed-slots
((total-daily-water-usage (+ (the building-1 daily-water-usage) (the building-2 daily-water-usage)))
(too-much-water-usage? (> (the total-daily-water-usage) (the max-allowed-daily-water-usage))))
:objects
((:building-1 :type (getf (the building-1-data) :type)
:parameters (rest (rest (the building-1-data))))
(:building-2 :type (getf (the building-2-data) :type)
:parameters (rest (rest (the building-2-data))))))
(define-object city-3 (box)
:input-slots
((length 10)
(width 10)
(height 0.25)
(max-allowed-daily-water-usage 5000)
(building-data '((:type bank :height 30 :width 70 :length 50)
(:type hotel :height 100 :width 40 :length 30))))
:computed-slots
((total-daily-water-usage
(apply #'+ (list-elements (the buildings) (the-element daily-water-usage))))
(too-much-water-usage?
(> (the total-daily-water-usage) (the max-allowed-daily-water-usage))))
:objects
((:buildings :type (:sequence (mapcar #'(lambda (plist) (getf plist :type))
(the building-data)))
:sequence (:size (length (the building-data)))
:parameters (rest (rest (nth (the-child index) (the building-data)))))))
(defparameter *city-data*
`(:buildings
((:type bank :height 30 :width 70 :length 50 :center ,(make-point 50 50 15))
(:type hotel :height 100 :width 40 :length 30 :center ,(make-point -50 -50 50)))))
(define-object city-4 (box)
:input-slots
((length 200)
(width 200)
(height 10)
(max-allowed-daily-water-usage 5000)
(building-data (getf *city-data* :buildings)))
:computed-slots
((display-controls (list :color :blue :transparency 0.5)))
:objects
((:buildings :type (:sequence (mapcar #'(lambda (plist) (getf plist :type)) (the building-data)))
:sequence (:size (length (the building-data)))
:center (getf (nth (the-child index) (the building-data)) :center)
:parameters (rest (rest (nth (the-child index) (the building-data)))))))
(defpart point-demo (null-geometric-object)
:attributes
(:point-1 (make-point 1 0 1) :point-2 (make-point 1 0 0)
:direction-vector (subtract-vectors (the point-2) (the point-1))))
(defpart translation-demo (null-geometric-object)
:attributes
(:point-1 (make-point 1 0 1) :point-2 (make-point 1 0 0) :direction-vector
(subtract-vectors (the point-2) (the point-1)) :midpoint
(translate-along-vector (the point-1) (the direction-vector)
(half (3d-distance (the point-1) (the point-2))))))
(defpart self-aligning-box (box)
:inputs (:top-vector :front-vector)
:attributes
(:orientation (alignment :top (the top-vector) :front (the front-vector))))
(define-object building (box))
(define-object bank (building)
:computed-slots
((daily-water-usage 2000)))
(define-object hotel (building)
:computed-slots
((daily-water-usage 4000)))
| 4,982 | Common Lisp | .lisp | 120 | 36.866667 | 102 | 0.654344 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 2c48e98abfdcb022aa2d088efbbd7c16857213af16f98d663357907b54b0893d | 36,104 | [
-1
] |
36,105 | assembly.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/slides/source/assembly.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g102; Base: 10 -*-
(in-package :training-g102)
(define-object assembly (slide-show-node)
:input-slots
((title "G102: GDL Quickstart")
(slide-package (find-package :training-g102))
(image-base-url "/g102/images/")
(style-url "/g102/style/top.css"))
:objects
(
(:session-01 :type 'session-01)
(:session-02 :type 'session-02)
(:session-03 :type 'session-03)
(:session-04 :type 'session-04)
(:session-05 :type 'session-05)
(:session-06 :type 'session-06)
(:session-07 :type 'session-07)
))
| 599 | Common Lisp | .lisp | 18 | 29.277778 | 77 | 0.661972 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 632212826f6d6e14961c1ae47d62d26c55824c615175fa1290fe3f2dcc21598b | 36,105 | [
-1
] |
36,106 | session-02.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/slides/source/session-02.lisp | (in-package :training-g102)
(define-object session-02 (slide-show-leaf)
:computed-slots
((strings-for-display "The define-object macro")
(slide-data `((:title "Syntax of the define-object macro" :bullet-points
((:description "definition (i.e. blueprint) of an object")
(:description "Can represent a physical part or assembly or any grouping of computational elements")
(:description
,(with-output-to-string (ss)
(html-stream ss
(:i "input-slots") ", " (:i "computed-slots") ", " (:i "objects"))))
(:description "Dynamic, Demand-Driven evaluation of objects and messages (order-independent)")
(:description "Graphical, web-based testing and tracking utility (TaTU)")
(:description "Edited and compiled in much the same fashion as normal CL code")))
(:title "defun vs. define-object"
:bullet-points
((:description
,(with-output-to-string (ss)
(html-stream ss "Purpose in Life"
((:table :border 1)
(:tr ((:th :width 0.5 :background "#BBDDFF") "defun")
((:th :width 0.5 :background "#BBFFDD") "define-object"))
(:tr
((:td :background "#CCEEFF")
"Accept some " (:i "Arguments")
", possibly perform some "
(:i "Side-effects")
", and compute one or more "
(:i "Return-values"))
((:td :background "#CCEEFF")
"Accept some "
(:i "input-slots")
", possibly perform some "
(:i "side-effects")
", and compute one or more "
(:i "Outputs.")))))) :suppress-end-dot? t)
(:description
,(with-output-to-string (ss)
(html-stream ss "How to Use"
((:table :border 1)
(:tr ((:th :width 0.5 :background "#BBDDFF") "defun")
((:th :width 0.5 :background "#BBDDFF") "define-object"))
(:tr
((:td :background "#CCEEFF")
"Generally you call it by name, by evaluating a Lisp expression")
((:td :background "#CCEEFF")
(:ol (:li "Create an " (:i "Instance"))
(:li "Send " (:i "Messages") " to the Instance")))))))
:suppress-end-dot? t)
(:description
,(with-output-to-string (ss)
(html-stream ss "How to Define"
((:table :border 1)
(:tr ((:th :width 0.5 :background "#BBDDFF") "defun")
((:th :width 0.5 :background "#BBDDFF") "define-object"))
(:tr
((:td :background "#CCEEFF")
(:code
(:pre
(:b "defun <i>name</i> <i>argument-list</i> <i>body</i>"))))
((:td :background "#CCEEFF")
(:code
(:pre
(:b "define-object <i>name</i> <i>mixin-list</i> <i>spec-plist</i>"))))))))
:suppress-end-dot? t)
(:description
,(with-output-to-string (ss)
(html-stream ss "How to Modularize"
((:table :border 1)
(:tr ((:th :width 0.5 :background "#BBDDFF") "defun")
((:th :width 0.5 :background "#BBDDFF") "define-object"))
(:tr
((:td :background "#CCEEFF")
(:code
(:pre
(:b "Call other functions from within a function"))))
((:td :background "#CCEEFF")
(:ol (:li "<i>Inherit</i> <i>slots</i> from other objects using <i>mixins</i>")
(:li "Include <i>instances</i> of other objects inside an object")))))))
:suppress-end-dot? t)))
(:title "Defun vs. Define-object, Cont'd" :bullet-points
((:description
,(with-output-to-string (ss)
(html-stream
ss "Advantages"
((:table :border 1)
(:tr ((:th :width 0.5 :background "#BBDDFF") "defun")
((:th :width 0.5 :background "#BBDDFF") "define-object"))
(:tr
((:td :background "#CCEEFF")
(:ol (:li "Works with Any Lisp (Including free implementations and Emacs Lisp!)")
(:li "Dynamic") (:li "Good for small, simple computations")))
((:td :background "#CCEEFF")
(:ol (:li "Declarative") (:li "Dynamic") (:li "No Need for Procedural Debugging")
(:li "Compile-Test-Debug cycle is <i>very</i> fast (important!)")
(:li "Built-in Geometric Primitives, output formats, and CAD Connections")))))))
:suppress-end-dot? t)
(:description
,(with-output-to-string (ss)
(html-stream
ss "Disadvantages"
((:table :border 1)
(:tr ((:th :width 0.5 :background "#BBDDFF") "defun")
((:th :width 0.5 :background "#BBDDFF") "define-object"))
(:tr
((:td :background "#CCEEFF")
(:ol (:li "Procedural (i.e. a Lisp program has a ``begin'' and ``end'')")
(:li "Sometimes Difficult to Debug when Long")
(:li "Compile-Test-Debug cycle much faster than C, but you still
must run through procedural code")))
((:td :background "#CCEEFF")
(:ol (:li "Requires GDL package and license")
(:li
"Can be more resource-intensive (RAM, swap space, disk space) -- tradeoff between space and time")))))))
:suppress-end-dot? t)))
(:title "Basic define-object Syntax" :bullet-points
((:description "<i>Define-object class-name mixin-list spec-plist</i>")
(:description "<i>class-name</i> is a symbol, just like a Defun name")
(:description "<i>Mixin-list</i> is a list of other <i>class-names</i>
from which this object definition (i.e. class) <i>inherits</i> characteristics")
(:description "The rest of the body of the define-object consists of a
<i>Spec-plist</i>, made up of special keywords and lists, which specify the
computational ``blueprint'' for this object")))
(:title "Basic Define-object Syntax, Cont'd: <i>:slots</i>"
:bullet-points
((:description "Almost every Spec-plist you see will have an <i>:input-slots</i>
and/or <i>:computed-slots</i> section. Slots are symbols, whose names you specify,
which represent intermediate and/or final <i>outputs</i> to be computed by an object."
:examples
((:define-object silly-object)))
(:description "As seen in the above example, each slot consists of a
<i>name</i> (i.e. a symbol specified by you), and an <i>expression</i> which can
be any valid CL expression")
(:description "Slots can refer to the value of other slots in the
same object using the macro <i>the</i>")
(:description "When we talk about the <i>value</i> of a slot, we are
referring to the <i>return-value</i> of its expression, in a particular <i>object instance</i>")))
(:title "<i>Instances</i> and <i>Sending Messages</i>"
:bullet-points
((:description "You can make an <i>instance</i> of a GDL object with the
function <i>make-object</i>:"
:examples
((:code (make-object 'silly-object)
:return-value* "<silly-object 26112>")))
(:description "You can send <i>messages</i> to a define-object instance
(e.g. to obtain <i>slot</i> values of the object) with
the macro <i>the-object</i>:"
:examples
((:code (setq obj (make-object 'silly-object)) :return-value* "<silly-object 26113>")
(:code (the-object obj b) :return-value 2500)))
(:description "If you only need to send one message, you can do it
all in one step:" :examples ((:code (the-object (make-object 'silly-object) b) :return-value 2500)))))
(:title "Specifying a define-object with input-slots" :bullet-points
((:description "Required Input-slots work similarly to Keyword Arguments to a defun,
but they are required (i.e. not optional) and have no default
(i.e. their values must be specified upon object instantiation)"
:examples
((:define-object silly-object-2)
(:define-object hello-there)))))
(:title "Specifying <i>input-slots</i> to an <i>object Instance</i>"
:bullet-points
((:description "In order for an object instance to
behave as expected, all required <i>input-slots</i> must be supplied at the
time of instantiation:"
:examples
((:code (setq obj (make-object 'hello-there :name "Jake" :fancy? nil))
:return-value* "<hello-there 26120>")
(:code (the-object obj greeting) :return-value "Hello Jake")
(:code (setq obj (make-object 'hello-there :name "Jake" :fancy? t)) :return-value
"<hello-there 26120>")
(:code (the-object obj :greeting) :return-value "Hello there Jake, How Are You?")))))
(:title "Specifying <i>input-slots</i> to an object Instance as a plist"
:bullet-points ((:description "Since the inputs to a define-object form a plist, you
can specify them as such using <i>Apply</i>:"
:examples
((:code (setq myparms (list :name "Jackson" :fancy? t))
:return-value (:name "Jackson" :fancy? t))
(:code (setq obj (apply #'make-object 'hello-there myparms))
:return-value* "<hello-there 26120>")
(:code (the-object obj :greeting)
:return-value "Hello there Jackson, How Are You?")))))
(:title "Using a Defun as a wrapper for demanding outputs from an Object"
:bullet-points
((:description "Often, it is convenient to be able to
call a function, while the actual work is done by an object instance:"
:examples
((:code
(defun print-greeting (&key (name "Jake") (fancy? t))
(format t "~a"
(the-object (make-object 'hello-there :name name :fancy? fancy?) greeting)))
:return-value print-greeting)
(:code (print-greeting) :print-string "Hello there Jake, How Are You?" :return-value nil)
(:code (print-greeting :name "Jackson")
:print-string "Hello there Jackson, How Are You?" :return-value nil)))))
(:title "The Special Variable <i>Self</i>" :bullet-points
((:description "<i>(The ...)</i> is equivalent to <i>(The-object self ...)</i>")
(:description "Within an object instance, the local variable <i>self</i> is
automatically set to that instance"
:examples
((:code (setq obj (make-object 'silly-object)) :return-value "<silly-object 57390>")
(:code (the-object obj b) :return-value 100)
(:code (the-object obj c) :return-value 100)))
(:description "You can also <i>setq</i> or <i>let</i> an object instance to
<i>self</i> at the toplevel or inside a defun, and send
messages using <i>the</i> instead of <i>the-object</i>:"
:examples
((:code (let ((self (make-object 'silly-object))) (the b)) :return-value 100)))
(:description "The ``<i>self</i>'' inside a GDL object instance is protected from
any other <i>self</i> bindings, so any ``<i>the</i>'' references inside
the object definition will always work properly")))
(:title "Exercises" :bullet-points
((:description "Write a define-object <i>silly-adder</i>, which has two
input-slots, <b>a</b> and <b>b</b>, and has computed-slot <b>sum</b> which is the sum of <b>a</b> and <b>b</b>")
(:description "
Test your object in four ways:
<ol>
<li>
<i>Setq</i> a variable to an instance at the top-level
(using <i>make-object</i>), then use <i>the-object</i> to send
the <b>sum</b> message to your instance.
</li>
<li>
Do it all in one nested statement, without <i>setq</i>ing any variables.
</li>
<li>
Create a wrapper function which <i>let</i>s a variable to an instance
of your object, then uses <i>the-object</i> within the body of the let.
</li>
<li>
Have the wrapper function <i>let</i> the local variable <i>self</i>
to an instance of the object, then use <i>the</i> within the body of
the let.
</li>
</ol>"
:suppress-end-dot? t)))))))
| 11,505 | Common Lisp | .lisp | 235 | 42.178723 | 112 | 0.622102 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 9ab9759127d7d31f182c1660e6f522efdaf20b8a0b35dafef1dae7ddd5ad029b | 36,106 | [
-1
] |
36,107 | session-01.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/slides/source/session-01.lisp | (in-package :training-g102)
(define-object session-01 (slide-show-leaf)
:computed-slots
((strings-for-display "Introduction")
(slide-data `((:title "Goals" :bullet-points
((:description "Get you <b>excited</b> about using General-purpose Declarative Language (GDL)")
(:description "Qualify all of you to read and develop GDL applications")
(:description "Enable you to Judge Whether GDL is an Appropriate Tool for a Given Job.")
(:description "Arm you with the ability to Argue the Case for using GDL when
it is the appropriate tool for the job")))
(:title "Topics Covered in G102" :bullet-points
((:description "The define-object macro, Overview")
(:description "define-object syntax")
(:description "Functional and Declarative Programming Style")
(:description "When to use objects and hidden-objects")
(:description "When to use object sequences and matrices")
(:description ,(with-output-to-string (ss)
(html-stream
ss
"Basic Overview of Geometric Objects"
(:ul (:li "Wireframe")
(:li "Surfaces")
(:li "Solids"))
"And when their use is appropriate")))
(:description "Performance Issues")))
(:title "Topics not Covered in G102" :bullet-points
((:description "Symbolic Positioning and Orienting of Geometry")
(:description "GWL Web User Interface")
(:description "Integrations with Specific CAD Systems")))
(:title "What is GDL?" :bullet-points
((:description "A Dynamic, Declarative, Object-oriented
Computational Language embedded in Common Lisp")
(:description "A Superset of Common Lisp (i.e. it gives you the entire
capabilities of CL, while allowing you to work
at a much higher level of abstraction)")
(:description "A technology which allows the engineer to organize
engineering problems and their solutions
according to a structure which naturally parallels the problem domain")
(:description "A good way to take advantage of modern advances
in computer processor speed and memory capacity, while freeing
the developer from mundane tasks normally associated with
computer programming")))
(:title "Dynamic, Declarative, Object-oriented"
:bullet-points
((:description "<i>Dynamic</i> refers to the ability to redefine objects
or change input data and see the results immediately, without restarting
a program from scratch. This <i><b>greatly</b></i> speeds development
when compared with traditional programming environments such as C and C++.")
(:description "<i>Declarative</i> refers to the ability to specify
units of computation (i.e. ``rules'') in a <b>totally order-independent manner</b>.
This becomes <b><i>very</i></b> important as models become large and complex")
(:description
,(with-output-to-string (ss)
(html-stream
ss
(:i "Object-oriented")
" refers to all the characteristics
normally associated with object-oriented programming, including:"
(:ul
(:li "separation between the definition of an object and an instance")
(:li "high levels of data abstraction")
(:li "the ability for one object to inherit from others"))
"GDL supports both the "
(:i "message-passing")
" and "
(:i "generic function")
" paradigms of object orientation (more on this later)")))))
(:title "Why GDL? (i.e. What is it Good For)"
:bullet-points
((:description "Organizing and interrelating large amounts of information
from different types of data sources")
(:description "Evaluating many design alternatives and performing optimizations
within specified design spaces")
(:description "Capturing the procedures and rules used to solve repetitive
tasks in engineering and other fields")
(:description "Applying these rules to achieve intermediate and final
outputs, which may include virtual models of wireframe, surface, and solid geometric objects")))
(:title "What is GDL not?"
:bullet-points
((:description "A drawing program")
(:description "An Artificial Intelligence
system (although it is an excellent environment for developing
capabilities which could be considered as such)")
(:description "An Expert System Shell (although one could be easily embedded within it)")))
(:title "Why not GDL? (i.e. What is it Not Good For?)"
:bullet-points
((:description "Creating brand new parts with artistic content and free-form geometry")
(:description "Perform traditional CAE tasks such as finite-element analysis and CFD
(although GDL is an excellent environment for pre- and post-processing
of data for such solvers, and managing batch runs of such solvers) ")))))))
| 4,765 | Common Lisp | .lisp | 90 | 47.544444 | 99 | 0.720472 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 0b8cd5eb37ba2b41127c05e3f358a0dcf07883fbb04a54a82af9eae6e11988fb | 36,107 | [
-1
] |
36,108 | session-05.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/slides/source/session-05.lisp | (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,043 | Common Lisp | .lisp | 76 | 50.407895 | 104 | 0.703788 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 94ee70662ebd7801241d99426a1ffaa24602397a1fa7b64e719baa6be87d9e0e | 36,108 | [
-1
] |
36,109 | session-06.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/slides/source/session-06.lisp | (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")))
| 766 | Common Lisp | .lisp | 17 | 41 | 79 | 0.721692 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 5d5f21f0ff652665b48c185783f8bc4386f9a4ae76092b54bc66465472a2371f | 36,109 | [
-1
] |
36,110 | session-04.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/slides/source/session-04.lisp | (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")))
| 1,227 | Common Lisp | .lisp | 30 | 36.5 | 88 | 0.699491 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 2396ae1f0ee0b68e59a8d32e715cbc1317a6efe9973c68111bf2193ffcc9dc72 | 36,110 | [
-1
] |
36,111 | session-07.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/slides/source/session-07.lisp | (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")))
| 1,766 | Common Lisp | .lisp | 46 | 33.869565 | 88 | 0.672738 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | b938eee5066cf1ccbfc7cd40c59f8b05bbfb71707ae83c6f0b46e17dbf2f0ded | 36,111 | [
-1
] |
36,112 | session-03.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/slides/source/session-03.lisp | (in-package :training-g102)
(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)))))))))
| 4,656 | Common Lisp | .lisp | 81 | 52.82716 | 112 | 0.690534 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | f5e8f0071356165361e239f29fc74511219ba1dcf28195779dc3e53571595c4b | 36,112 | [
-1
] |
36,113 | exports.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/slides/source/exports.lisp | (in-package :training-g102)
#+nil
(http:export-url #u"/training/g102/images/"
:image-directory
:pathname (translate-logical-pathname "genworks:web;training;g102;images;")
:recursive-p t
:immediate-export t)
#+nil
(http:export-url #u"/training/g102/examples/"
:directory
:pathname (translate-logical-pathname "genworks:web;training;g102;examples;")
:immediate-export t
:recursive-p t)
#+nil
(http:export-url #u"/training/g102/exercises/"
:directory
:pathname (translate-logical-pathname "genworks:web;training;g102;exercises;")
:immediate-export t
:recursive-p t)
| 580 | Common Lisp | .lisp | 19 | 28.631579 | 79 | 0.776978 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 7fb39bbeac1f3c8dfbd879fe1100e31e18ce302b3278faed4a6f4e76b2c5587f | 36,113 | [
-1
] |
36,114 | assembly.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/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-view (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) | 68e8d6f70ed6e659bdebdd694a510793cc1a38825ef61169a853c32860432604 | 36,114 | [
-1
] |
36,115 | building.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/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.
;;
(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)))
(define-object proximity-rule ()
:input-slots (current-building neighbors target-type distance)
: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)))))))
| 3,797 | Common Lisp | .lisp | 90 | 36.511111 | 89 | 0.679604 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 39de9761c25b57811d479e7542e7bc27a48473d81b0866c9c62c8124fda15622 | 36,115 | [
-1
] |
36,118 | ackermann-assembly.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/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. Enabled 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) | 2d8f63ff07b59d42dcc4b6a354b5d6577a812cc10eb3f9e1ebea6276267fbb31 | 36,118 | [
-1
] |
36,120 | package.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/source/package.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: user; Base: 10 -*-
(in-package :user)
(gwl:define-package :training-g102 (:use :slide-show) (:export #:assembly))
| 168 | Common Lisp | .lisp | 3 | 54 | 76 | 0.666667 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 540d86998e247ce497eccd9e024d49e2c9d420980b9e96ab56de2823e33c150e | 36,120 | [
-1
] |
36,121 | publish.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g102/source/publish.lisp | (in-package :training-g102)
(publish :path "/training-g102"
:function #'(lambda(req ent)
(gwl-make-object req ent "training-g102:assembly")))
(publish-directory :prefix "/g102/images/"
:destination (format nil "~a" (translate-logical-pathname "~/genworks/gwl-apps/training/g102/images/")))
(publish-directory :prefix "/g102/style/"
:destination (format nil "~a" (translate-logical-pathname "~/genworks/gwl-apps/training/g101/style/")))
| 460 | Common Lisp | .lisp | 8 | 53.5 | 109 | 0.714922 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 36f2a255af6496a2990d9fcfc28d58d4e38a48b76fcf74dc1e5eaf9fbb2ceede | 36,121 | [
-1
] |
36,122 | solutions.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/examples/source/solutions.lisp | (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,008 | Common Lisp | .lisp | 59 | 29.20339 | 66 | 0.612853 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 622630bac0b4bd0abb34200dd962a4f6d80c55a2b8419fd5decdc02bcbf6b106 | 36,122 | [
-1
] |
36,123 | assembly.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/assembly.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(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 "/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)
))
| 807 | Common Lisp | .lisp | 22 | 32.909091 | 77 | 0.622909 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 798ee097a4edbbeb2f360e2d6ab6738dd51a1ed74cae4be2b87eb402ab24b2b8 | 36,123 | [
-1
] |
36,124 | symbols.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/symbols.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(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).")))))))
| 1,812 | Common Lisp | .lisp | 43 | 37.790698 | 101 | 0.691867 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 501544460a8722e2f2e86be8456253f46d5325dc6c6afd815ab49ab2188a9426 | 36,124 | [
-1
] |
36,125 | input-output.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/input-output.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(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 &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 &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>==>''</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.")))))))
| 11,559 | Common Lisp | .lisp | 268 | 38.615672 | 108 | 0.684624 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a50d1de9595d2bd5c5670f37a39be1378d7a8e4140a026338beee047a19bd483 | 36,125 | [
-1
] |
36,126 | introduction.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/introduction.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(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 12 years running Genworks, a KBE tools vendor")
(:description
"1993-1997: at Ford Motor, 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 "Experience in Database Industry (Quantum/Progress)")
(:li "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)")))))))
| 2,560 | Common Lisp | .lisp | 67 | 32.761194 | 100 | 0.681837 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | f6821d536799b2355b53aa8cd2f4a832b62fb9bf15e18b4c50e3f14d3c7d699f | 36,126 | [
-1
] |
36,127 | data-structures.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/data-structures.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(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) :horrible)
:return-value :horrible)
(:code
(gethash :windows os-ratings)
:return-value :horrible)))
(: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.")))))))
| 2,838 | Common Lisp | .lisp | 68 | 37.705882 | 133 | 0.717098 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | b75b8888fd49fc07995d84006fa152dbb4e865df8ffa11f35d26492487d36d94 | 36,127 | [
-1
] |
36,128 | control.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/control.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(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 "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 "Red is actually her favorite color")
(:green "Are you nuts?")))
:return-value "Red is actually her favorite color")))
(: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.")))))))
| 7,134 | Common Lisp | .lisp | 209 | 28.110048 | 131 | 0.616444 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 5e75492d1a85b6e10faf0fd52a620196b373dae06204be15721dea3cfd16ead7 | 36,128 | [
-1
] |
36,129 | numbers.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/numbers.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(in-package :training-g101)
(defpart numbers (slide-show-leaf)
:uncached-attributes
(:strings-for-display "Numbers")
:attributes
(: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: ``>,'' ``<,'' ``<=,'' ``>=,'' 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))))))))
| 3,756 | Common Lisp | .lisp | 129 | 22.085271 | 106 | 0.553161 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 63f3ad52ee25d27bf281641c299feccdcb67951f5289c54e8f6e86770b04204b | 36,129 | [
-1
] |
36,130 | functions.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/functions.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(in-package :training-g101)
(defpart functions (slide-show-leaf)
:uncached-attributes
(:strings-for-display "Functions")
:attributes
(: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 '(6 4 3 9) #'<)
:return-value (3 4 6 9))
(:code
(sort '(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<</i>
or <i>String></i>. More on <i>Strings</i> later."
:examples
((:code
(sort '((4 "Buffy") (2 "Keiko") (1 "Judy") (3 "Aruna"))
#'(lambda(x y)
(< (first x) (first y))))
:return-value ((1 "Judy") (2 "Keiko") (3 "Aruna") (4 "Buffy")))
(:code
(sort '((1 "Judy") (2 "Keiko") (3 "Aruna") (4 "Buffy"))
#'(lambda(x y)
(string< (second x) (second y))))
: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<</i> and <i>string></i> to compare strings.</li>
<li>Of course, you can just use < and > 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."))))))
| 11,190 | Common Lisp | .lisp | 305 | 31.357377 | 132 | 0.608096 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 0e8330ae0e250269b9d30884811481d360b1ecdebdfd108ef3b3a787425d28a1 | 36,130 | [
-1
] |
36,131 | lists.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/lists.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(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* '(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 define 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 '(: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))))))))))
| 12,470 | Common Lisp | .lisp | 424 | 24.34434 | 114 | 0.628716 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 0a4224244ba97f40983c4f273b32b0f47045d900f7728da3cfbec34b3ccdabd8 | 36,131 | [
-1
] |
36,132 | conclusion.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/conclusion.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(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.alu.org/alu/res-lisp") "Association of Lisp Users")))
" 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 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.")))))))
| 1,580 | Common Lisp | .lisp | 28 | 51.5 | 156 | 0.712621 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 506846d0eb377820311aeefb0929778cfc4646fe6b8b1bd5384e567cd4b705a8 | 36,132 | [
-1
] |
36,133 | macros.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/macros.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(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 "~&<~(~A~)>~%" ',tag)
,@body
(format t "~&</~(~A~)>~%" ',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.")))))))
| 3,841 | Common Lisp | .lisp | 102 | 31.343137 | 121 | 0.608931 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 77128d2c9fab3754ab538f29f894d039cbc9fda8817fc9d091cbcdad837ee589 | 36,133 | [
-1
] |
36,134 | welcome.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/slides/source/welcome.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g101; Base: 10 -*-
(in-package :training-g101)
(define-object welcome (slide-show-leaf)
:computed-slots
((strings-for-display "Welcome to Lisp")
(:slide-data
'((:title
"Description of Lisp 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
"When Arguments are 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
"Any number of arguments"
:examples
((:code
(+)
:return-value
0)
(:code
(+ 1)
:return-value
1)))))
(:title
"Turning off Evaluation"
:bullet-points
((:description
"(+ 1 2) evaluates to 3")
(:description
"Sometimes you want to turn off expression evaluation")
(:description
"(quote (+ 1 2)) evaluates to (+ 1 2)")
(:description
"Common Lisp defines ' as an abbreviation for quote")
(:description
"'(+ 1 2) evaluates to (+ 1 2)")))
(: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 or Lisp will assume you are calling
a function (e.g. red)"
: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 (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 or setf 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* '(NT Solaris Irix HP-UX AIX))
:return-value (NT Solaris Irix HP-UX AIX))
(:code (setf (first *operating-systems*) 'Linux) :return-value Linux)
(:code *operating-systems* :return-value (Linux Solaris Irix HP-UX AIX))))))
(: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)))))))))
| 10,323 | Common Lisp | .lisp | 368 | 23.160326 | 126 | 0.642609 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | da79d7bb177a59fde0922c5852daacd759e6d7259e93511a1fa5251a7dfc8227 | 36,134 | [
-1
] |
36,135 | solutions.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/exercises/source/solutions.lisp | (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
"
(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 b 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))))))
| 4,336 | Common Lisp | .lisp | 126 | 30.547619 | 88 | 0.663359 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 736d065b3ced71efeaed11d146c30220d50a258a95f6b1d688c4b26276c9751d | 36,135 | [
-1
] |
36,136 | skeleton.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/exercises/source/skeleton.lisp | (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))))))
| 3,538 | Common Lisp | .lisp | 105 | 29.771429 | 88 | 0.66887 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 3dbd0372bce1b156bf1af9cd540339f206a89a39a364f8148a3dbe7fc8c137fa | 36,136 | [
-1
] |
36,137 | package.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g101/source/package.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: user; Base: 10 -*-
(in-package :gdl-user)
(gwl:define-package :training-g101 (:use :slide-show) (:export #:assembly))
| 171 | 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) | b424ab8240a3adba4af41b23a35eb6e751480c4089c53db06194afc9a570d894 | 36,137 | [
-1
] |
36,138 | publish.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/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/gwl-apps/training/g101/images/")))
(publish-directory :prefix "/g101/style/"
:destination (format nil "~a" (translate-logical-pathname "~/genworks/gwl-apps/training/g101/style/")))
| 460 | Common Lisp | .lisp | 8 | 53.5 | 109 | 0.714922 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 175b266fa5595cc516b41699b63b9df2629f4ba4c2d482d5774086cc09da641f | 36,138 | [
-1
] |
36,139 | drilled-block.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g105/examples/source/drilled-block.lisp | ;;(in-package :training-g105)
(in-package :gdl-surf-user)
(defun dmapcar (function list)
(dmapc function list)
(mapcar function list))
(defun dmapc (function list)
(let ((count -1))
(mapc #'(lambda(element)
(mp:process-run-function
(format nil "thread ~a from dmapcar" (incf count))
function element)) list)))
(define-object dgdl-test (base-object)
:input-slots
((length 10)
(width 20)
(height 30)
(hole-radius 2 :settable)
(hole-length 35)
(quantity 8 :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))
(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?)
(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 ()
:functions
((clear-remotes
()
(clrhash gwl::*remote-objects-hash*))
(global-gc
()
(gc t))
(reload
()
(gdl-user::g105))))
(define-object drilled-block (base-object)
:input-slots
(length width height hole-radius hole-length
(quantity 50 :settable))
:computed-slots ((volume (sum-elements (the results) (the-element volume))))
:objects
((results :type 'subtracted-solid
:sequence (:size (the quantity))
: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))))
| 2,443 | Common Lisp | .lisp | 73 | 28.136986 | 78 | 0.67045 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | c31fdb3482b4a7cfd8fbd80826a41830a384df1e0fdfb07f2449a5ae90da2b74 | 36,139 | [
-1
] |
36,140 | assembly.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g105/slides/source/assembly.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g102; Base: 10 -*-
(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)
))
| 454 | Common Lisp | .lisp | 13 | 30.384615 | 77 | 0.68171 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | e14a3db7621000242248fe9f37acea0da5f7bce0d3d2702d982800b11bc30a7d | 36,140 | [
-1
] |
36,141 | session-02.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g105/slides/source/session-02.lisp | (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)))))))))
| 324 | Common Lisp | .lisp | 8 | 36 | 64 | 0.703226 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | e500276097c2f3bcf12129b55f39077aaf965a615a27f4880488ceae16b622dc | 36,141 | [
-1
] |
36,142 | session-01.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g105/slides/source/session-01.lisp | (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")))))
| 910 | Common Lisp | .lisp | 15 | 55 | 115 | 0.731959 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 3c6854c1d2aa7ab28322e995325caf61d18f6a7a7e90e47c3ac1fe5667d0373e | 36,142 | [
-1
] |
36,143 | package.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g105/source/package.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: user; Base: 10 -*-
(in-package :gdl-user)
(gwl:define-package :training-g105 (:use :surf :slide-show) (:export #:assembly))
| 178 | Common Lisp | .lisp | 3 | 57.333333 | 82 | 0.668605 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | b8838400eb7ea41b6101299eeeafeec7f670b91b173c07ac37ba488c2d8907ad | 36,143 | [
-1
] |
36,144 | publish.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g105/source/publish.lisp | (in-package :training-g102)
(publish :path "/training-g105"
:function #'(lambda(req ent)
(gwl-make-object req ent "training-g105:assembly")))
| 155 | Common Lisp | .lisp | 4 | 34.5 | 61 | 0.691275 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 55d3632b57cc6d8b2d188e954fd595c82c77e40164ab5cbe8e34445d98f1dd54 | 36,144 | [
-1
] |
36,145 | hey-now.lisp | lisp-mirror_gendl/documentation/historical/doc/training-slides/g103/examples/source/hey-now.lisp | (in-package :gwl-user)
(eval-when (compile load)
(use-package :surf)
(export 'index))
(define-object index (base-html-sheet)
:objects
((named-box-1 :type 'hey-now)
(named-box-2 :type 'hey-now)))
(define-view (html-format index)()
:output-functions
((main-sheet
()
(html
(:html
(:head (:title "List of Boxes"))
(:body (:h2 (:center "List of Boxes"))
(:ul
(dolist (child (the children))
(html (:li (the-object child
write-self-link)))))))))))
(define-object hey-now (base-html-graphics-sheet)
:computed-slots
((iges-url (let ((url (format nil "/iges-~a.igs"
(the instance-id))))
(publish
:path url
:function
#'(lambda(req ent)
(with-http-response
(req ent :content-type "model/iges")
(with-http-body (req ent)
(let ((stream
(request-reply-stream req)))
(with-format (iges stream)
(write-the box cad-output)))))))
url))
(username "Jake" :settable)
(universal-time (get-universal-time))
(time-string (multiple-value-bind
(seconds minutes hours date month year)
(get-decoded-time)
(format nil "~a:~a:~a, ~a-~a-~a"
hours minutes seconds
year month date))))
:objects
((box :type 'surf::test-b-spline-surface)
(view-object :type 'web-drawing
:page-width 500
:page-length 300
:projection-vector
(getf *standard-views* :trimetric)
:objects (list (the box))))
:functions
((before-present!
()
(format t "I am in the before-present!~%"))
(after-present!
()
(format t "I am in the after-present!~%"))
(before-set!
()
(format t "I am in the before-set!~%"))
(after-set!
()
(format t "I am in the after-set!~%"))))
(define-view (html-format hey-now) ()
:output-functions
((main-sheet
()
(html (:html (:head (:title "Hey Now"))
((:body :bgcolor "#eeeeee")
(the write-development-links)
(the write-back-link)
(with-html-form ()
(:p ((:input :type :text
:name :username
:value (the username))))
((:a :href (the iges-url))
"Download an IGES file of this thing")
(:p ((:input :type :submit
:name :accept
:value " OK ")))
(the write-geometry))
(:h1 "Hey now " (:princ (the username)))
(:p "The time is now: "
(:princ (the time-string)))))))))
(publish :path "/index"
:function #'(lambda(req ent)
(gwl-make-object req ent
"gwl-user:index")))
| 2,562 | Common Lisp | .lisp | 90 | 22.555556 | 51 | 0.594969 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | f22c4b9aa4274864d7c41261f1d6f85ee31d4c96876445890ff0536b1f47bf9a | 36,145 | [
-1
] |
36,146 | examples.lisp | lisp-mirror_gendl/documentation/training/g108/examples/source/examples.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-g108)
(define-object hello-world (base-ajax-sheet)
:computed-slots
((main-sheet-body (with-cl-who-string ()
"Hello, World!"))))
(publish-gwl-app "/hello-world"
"training-g108::hello-world")
(define-object hello-world-htm (base-ajax-sheet)
:computed-slots
((main-sheet-body (with-cl-who-string ()
(:p
(:b (:i "Hello, World!")))))))
(publish-gwl-app "/hello-world-htm"
"training-g108::hello-world-htm")
(define-object revenue-table (base-ajax-sheet)
:input-slots
((sample-table-data '(("Year" "Revenue")
(2003 25000)
(2004 34000)
(2005 21000)
(2006 37000)
(2007 48000)
(2008 54000)
(2009 78000))))
:computed-slots
((main-sheet-body
(with-cl-who-string ()
(:p
((:table :border 1)
(:tr (dolist (cell (first (the sample-table-data)))
(htm (:th (str cell)))))
(dolist (row (rest (the sample-table-data)))
(htm (:tr
(dolist (cell row)
(htm (:td (str cell)))))))))))))
(publish-gwl-app "/revenue-table"
"training-g108::revenue-table")
(define-object revenue-table (base-ajax-sheet)
:computed-slots
((sample-table-data '(("Year" "Revenue")
(2003 25000)
(2004 34000)
(2005 21000)
(2006 37000)
(2007 48000)
(2008 54000)
(2009 78000)))
(main-sheet-body
(with-cl-who-string ()
(:p
((:table :border 1)
(:tr (dolist (cell (first (the sample-table-data)))
(htm (:th (str cell)))))
(dolist (row (rest (the sample-table-data)))
(htm (:tr
(dolist (cell row)
(htm (:td (str cell)))))))))))))
(define-object text-form (base-ajax-sheet)
:computed-slots
((main-sheet-body
(the main-area main-div))
(result (* (the number-input value) 2)))
:functions ((restore-defaults!
()
(the number-input :restore-defaults!)))
:objects ((reset :type 'button-form-control
:label "Reset"
:onclick (the (gdl-ajax-call :function-key :restore-defaults!)))
(number-input :type 'text-form-control
:prompt "Enter a number"
:default 42
)
(main-area :type 'sheet-section
;;
;; FLAG -- use :inner-html instead of :main-view starting in 1581!
;;
:main-view (with-cl-who-string ()
(with-html-form (:cl-who? t)
(:p (str (the number-input html-string)) :br
((:input :type :submit :value "ok"))
" "
(str (the reset form-control-string)))
(:p (str (the result))))))))
(publish-gwl-app "/text-form"
"training-g108::text-form")
;;
;; Basic UI with graphics area
;;
(define-object box-with-inputs (base-ajax-sheet)
:computed-slots
(
#+nil
(html-sections (list (the inputs-section)
(the top-viewport-section)
(the tri-viewport-section)))
(box-width nil :settable)
(use-raphael? t)
(main-sheet-body
(with-cl-who-string ()
(:p (when *developing?* (the write-development-links)))
(:p ((:span
:style "cursor: pointer;"
:onclick (the (gdl-ajax-call :function-key
:print-time)))
"Click here"))
(:p
(str (the inputs-section main-div)))
(:table
(:tr
(:td (str (the top-viewport-section main-div)))
(:td (str (the tri-viewport-section main-div)))
)))))
:functions
((print-time
()
(format *trace-output* "~a" (get-universal-time)))
(print-root-path
(object &key fancy?)
(let ((root-path (the-object object root-path)))
(format *trace-output* "~&~s~%" root-path))
(when fancy?
(format *trace-output* "isn't that fancy?~%"))))
:objects
((box :type 'box
:height 10
:width (or (the box-width)
(the inputs-section box-width))
:length (the inputs-section box-length))
(inputs-section :type 'inputs-section
:box-width-default (the box-width))
(top-viewport-section :type 'base-ajax-graphics-sheet
:view-direction-default :top
:image-format-default :raphael
:display-list-objects (list (the box))
:length 300
:width 300)
(tri-viewport-section :type 'base-ajax-graphics-sheet
:view-direction-default :trimetric
:image-format-default :raphael
:display-list-objects (list (the box))
:length 300
:width 300)))
(define-object inputs-section (sheet-section)
:input-slots
(box-width-default)
:computed-slots
((box-length (the box-length-input value))
(box-width (the box-width-input value))
(inner-html (with-cl-who-string ()
(:p (str (the box-length-input html-string)))
(:p (str (the box-width-input html-string)))
(:p (str (the button form-control-string)))
)))
:objects
((button :type 'button-form-control
:label " Reset "
:onclick (the (gdl-ajax-call :function-key
:restore-defaults!)))
(box-width-input :type 'text-form-control
:default (or (the box-width-default) 25)
:allow-invalid? nil
:validation-function #'(lambda(width)
(< 10 width 30))
:size (length (format nil "~a" (the-child value)))
:prompt "Box Width: "
:ajax-submit-on-change? t)
(box-length-input :type 'text-form-control
:default 42
:prompt "Box Length: "
:ajax-submit-on-change? t))
:functions
((restore-defaults!
()
(format t "~&Should restore defaults.~%~%")
(the box-width-input (restore-slot-default! :value))
(the box-length-input (restore-slot-default! :value))
)))
(publish-gwl-app "/box-with-inputs"
"training-g108::box-with-inputs")
(define-object readable-inputs-form (base-ajax-sheet)
:computed-slots
((main-sheet-body
(with-cl-who-string ()
(str (the development-links))
(with-html-form (:cl-who? t)
(:p (str (the expression-input form-control-string)) :br
(str (the symbol-input form-control-string)) :br
((:input :type :submit :value "ok"))))
(print-variables (the expression-input value))
(:p "Value is: "
(str (escape-string
(format nil "~s" (the expression-input value))))))))
:objects ((expression-input :type 'text-form-control
:domain :pass-thru
:prompt "Enter an expression"
:default 42)
(symbol-input :type 'text-form-control
:domain :pass-thru
:prompt "Enter an expression"
:default t)
))
(publish-gwl-app "/rif"
"training-g108::readable-inputs-form")
(define-object stretch-box (box)
:computed-slots
(
(display-controls (list :color :green))
(label "hey now
man
here is another line" :settable)
(length 10 :settable)
(width 10 :settable)
(height 10 :settable))
:objects
((box :type 'stretch-box)))
| 9,075 | Common Lisp | .lisp | 235 | 26.991489 | 75 | 0.537816 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | d72202f4537c19a5a562005837019d9e58e162566218eabfdd52b905d322cbeb | 36,146 | [
-1
] |
36,147 | assembly.lisp | lisp-mirror_gendl/documentation/training/g108/slides/source/assembly.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: training-g102; Base: 10 -*-
(in-package :training-g108)
(define-object assembly (slide-show-node)
:input-slots
((title "G108: Web/Ajax User Interface")
(slide-package (find-package :training-g108))
(image-base-url "/g108/images/")
(style-url "/static/gwl/style/top.css"))
:objects
(
(session-01 :type 'basic-sheet)
(session-02 :type 'ajax-sections)
))
| 448 | Common Lisp | .lisp | 13 | 29.923077 | 77 | 0.679518 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | fa18a7772bb6953afecfa9375c44ded63a305d101ffff03b72e677c534b52262 | 36,147 | [
-1
] |
36,148 | ajax-sections.lisp | lisp-mirror_gendl/documentation/training/g108/slides/source/ajax-sections.lisp | (in-package :training-g108)
(define-object ajax-sections (slide-show-leaf)
:computed-slots
((strings-for-display "Updating Page Sections with Ajax")
(slide-data `((:title "Using text-form-control"
:bullet-points
((:description "text-form-control for type-in values")
(:description "Can be string, number, symbol, or list")
(:description
"Must decompose the page into at least one section"
:examples
((:define-object inputs-outputs)
(:define-object inputs-outputs-page-content)
))))))))
| 562 | Common Lisp | .lisp | 14 | 33.714286 | 60 | 0.688091 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 88eb4c1a709248e92af25d3c9531e0359aec8195a43a32fd1636653485312623 | 36,148 | [
-1
] |
36,149 | basic-sheet.lisp | lisp-mirror_gendl/documentation/training/g108/slides/source/basic-sheet.lisp | (in-package :training-g108)
(define-object basic-sheet (slide-show-leaf)
:computed-slots
((strings-for-display "Making a basic web page with Data from your Application")
(slide-data `((:title "Goals for G108" :bullet-points
((:description "Create a basic static web page from information in your application.")
(:description "Allow user interaction with the model (i.e. changing or \"bashing\" values).")
(:description "Include geometry display (vector, raster, and shaded) in your application.")))
(:title "The <tt>base-ajax-sheet</tt> Primitive"
:bullet-points
((:description
"Basic mixin for representing a web page"
:examples
((:code (gwl:define-package :training-g108))
(:code (in-package :training-g108))
(:define-object hello-world)
(:code (publish-gwl-app "/hello-world"
"training-g108::hello-world"))))
(:description
"With the above code, you can visit in your browser:
http://localhost:9000/hello-world
")))
(:title "<tt>with-cl-who</tt> and <tt>with-cl-who-string</tt> syntax"
:bullet-points
((:description
"cl-who converts LHTML into standard HTML")
(:description
,(with-cl-who-string ()
"Full docs available from "
((:a :href "http://www.weitz.de/cl-who/") " Here ")))
(:description
"LHTML markup uses keyword and nested parentheses instead of raw HTML markup tags:"
:examples
((:code (in-package :training-g108))
(:define-object hello-world-htm)
(:code (publish-gwl-app "/hello-world-htm"
"training-g108::hello-world-htm"))
))
(:description
"Sheet will normally be in Standard Compliance mode now.")
#+nil
(:description
,(with-cl-who-string ()
((:img :src "/g108/images/hello-world-htm.png")))))
)
(:title "Generating Dynamic Content"
:bullet-points
((:description
"You can drop into normal Lisp/GDL at any time within
cl-who markup")
(:description
"To get back to cl-who, use the htm directive"
:examples
((:code (in-package :training-g108))
(:define-object revenue-table)
(:code (publish-gwl-app "/revenue-table"
"training-g108::revenue-table"))
))))))))
| 2,331 | Common Lisp | .lisp | 58 | 32.982759 | 98 | 0.644856 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | b779a8bd493fcd9c84ae84257140efc2c65bd502f8f543494face55927295e32 | 36,149 | [
-1
] |
36,150 | package.lisp | lisp-mirror_gendl/documentation/training/g108/source/package.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: user; Base: 10 -*-
(in-package :gdl-user)
(gwl:define-package :training-g108 (:use :slide-show) (:export #:assembly #:stretch-box))
| 186 | Common Lisp | .lisp | 3 | 60 | 90 | 0.672222 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 680ea8c8ea82f119a45de1af39817bddbe896c476194b4f57de20d110b3b1226 | 36,150 | [
-1
] |
36,151 | publish.lisp | lisp-mirror_gendl/documentation/training/g108/source/publish.lisp | (in-package :training-g108)
(publish :path "/training-g108"
:function #'(lambda(req ent)
(gwl-make-object req ent "training-g108:assembly")))
(defparameter *images-path* (merge-pathnames "documentation/training/g108/images/" glisp:*gendl-source-home*))
(publish-directory :prefix "/g108/images/" :destination (format nil "~a" *images-path*))
| 359 | Common Lisp | .lisp | 6 | 56 | 110 | 0.729107 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | c9bab7a185e492a02dfcaf4cbb61d2db08817c83a0f27098beb1adec907dd5b2 | 36,151 | [
-1
] |
36,152 | airfoil.lisp | lisp-mirror_gendl/documentation/training/g102/submissions/airfoil.lisp | ;;; Airfoil exercise AE4-232
;;; 9 March 09
;;; Cory Cooper
;;; builds a symmetric airfoil from a leading-edge radius and two joined lines
;;; takes in the chord and 'NACA last two' (percent chord) for thickness
;;; however, resulting airfoil does not represent true NACA 00xx shape
(in-package :gdl-user)
(define-object airfoil-basic (composed-curve)
:input-slots
((chord 2)
(NACA-last-two 12))
:computed-slots
((curves
(list (the leading-edge)
(the top)
(the bottom))))
:hidden-objects
((leading-edge
:type 'arc-curve
:center (make-point 0 0 0)
:radius (half (* (* .01 (the NACA-last-two)) (the chord)))
:start-angle (* 0.5 pi)
:end-angle (* -0.5 pi))
(top
:type 'linear-curve
:start (the leading-edge end)
:end (make-point (- (the chord)
(the leading-edge radius))
0 0))
(bottom
:type 'linear-curve
:start (the leading-edge start)
:end (the top end))))
| 1,008 | Common Lisp | .lisp | 33 | 24.939394 | 79 | 0.631078 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | c0186f7f909fea92850731d729386906564cd8e1e03e5fa6f255bc8013531429 | 36,152 | [
-1
] |
36,153 | ccooper.lisp | lisp-mirror_gendl/documentation/training/g102/submissions/ccooper.lisp | ;;; Fuselage example in GDL
;;; 2 Mar 09
;;; Cory Cooper
(in-package :gdl-user)
(define-object fuselage (base-object)
:input-slots
((length 30)
(width 10)
(height 5)
(diameter 5))
:objects
((refbox :type 'box)
(nose
:type 'fuselage-cone ;use this type because I defined it earlier?
:length (* (the length) 0.15) ;smarter way to define taper ratio?
:radius-1 (the diameter)
:number-of-sections 25
:center (translate (the (face-center :rear))
:front
(half (the-child length))))
(hull
:type 'fuselage-cylinder
:length (- (the length) (the nose length) (the tail-cone length))
:radius (the diameter)
:center (translate (the nose (face-center :front))
:front (half (the-child length))))
(tail-cone
:type 'fuselage-cone
:number-of-sections 25
:length (* (the length) 0.25)
:radius-1 0
:radius-2 (the diameter)
:center (translate (the (face-center :front))
:rear
(half (the-child length))))))
(define-object fuselage-cylinder (cylinder) ; create a basic cylinder
:input-slots
((length 10)
(radius 5)))
(define-object fuselage-cone (cone) ; create a cone
:input-slots
((length 7)
(radius-1 5)
(radius-2 3)
(number-of-sections 5)))
| 1,415 | Common Lisp | .lisp | 45 | 24 | 71 | 0.608762 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | ec2e2db13e7f23f0afc973a804a38f5b02a7c075f2c7e8a6697f5ac2f64b3ddf | 36,153 | [
-1
] |
36,155 | island-testing.lisp | lisp-mirror_gendl/documentation/training/g102/submissions/ccooper/source/island-testing.lisp | (in-package :gdl-user)
(define-object island-testing ()
:input-slots
()
:objects
((surface1 :type 'planar-surface
:p00 (make-point 0 0 0)
:p01 (make-point 1 0 0)
:p11 (make-point 1 1 0)
:p10 (make-point 0 1 0))
(surface2 :type 'planar-surface
:p00 (make-point 0 0 0)
:p01 (make-point 0 1 0)
:p11 (make-point 1 1 0)
:p10 (make-point 1 0 0))
(surface3 :type 'planar-surface
:p00 (make-point 0 1 0)
:p01 (make-point 1 1 0)
:p11 (make-point 1 0 0)
:p10 (make-point 0 0 0))
(surface4 :type 'planar-surface
:p00 (make-point 1 0 0)
:p01 (make-point 1 1 0)
:p11 (make-point 0 1 0)
:p10 (make-point 0 0 0))
(curve :type 'b-spline-curve
:control-points (list (make-point 0.2 0.2 .001)
(make-point 0.4 0.5 .001)
(make-point 0.7 0.6 .001)
(make-point 0.5 0.8 .001)
(make-point 0.3 0.4 .001)
(make-point 0.2 0.2 .001)))
(drop-curves :type 'dropped-curve
:sequence (:size 4)
:surface (nth (the-child index)(list (the surface1)
(the surface2)
(the surface3)
(the surface4)))
:curve-in (the curve))
))
| 1,264 | Common Lisp | .lisp | 40 | 23.65 | 55 | 0.561059 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 72441939ad893d9e762f271b2593a191f1f747e228d8e1d42107569ba8246dd8 | 36,155 | [
-1
] |
36,156 | aircraft-example.lisp | lisp-mirror_gendl/documentation/training/g102/submissions/ccooper/source/aircraft-example.lisp | ;;; Aircraft Exercise AE4-232
;;; 11 March 09
;;; Cory Cooper
;;;
;;;
;;;
(in-package :gdl-user)
(define-object aircraft-basic (base-object)
:input-slots
((length 30)
(fuselage-diameter 3)
(wing-root-chord 3)
(horz-tail-root-chord 2)
(vert-tail-root-chord 2)
(wing-root-NACA-last-two 12)
(wing-tip-NACA-last-two 12)
(horz-tail-root-NACA-last-two 12)
(horz-tail-tip-NACA-last-two 12)
(vert-tail-root-NACA-last-two 12)
(vert-tail-wing-tip-NACA-last-two 12)
(wing-taper 0.6)
(horz-tail-taper 0.8)
(vert-tail-taper 0.8)
(wing-twist -10)
(horz-tail-twist 0)
(wing-span 15)
(horz-tail-span 5)
(wing-sweep 10) ;in degrees
(horz-tail-sweep 10) ;in degrees
) ;include aspect ratio in lieu of span-chord??
:computed-slots
(display-controls (list :color "#0000FF"
:isos (list :n-u 25 :n-v 10)))
:objects
((fuselage ;creates the fuselage
:type 'fuselage
:length (the length)
:diameter (the fuselage-diameter))
(right-wing ;creates the right wing
:type 'wing-basic
:root-chord (the wing-root-chord)
:root-NACA-last-two (the wing-root-NACA-last-two)
:tip-NACA-last-two (the wing-tip-NACA-last-two)
:wing-length (half (the wing-span))
:taper (the wing-taper)
:twist (the wing-twist)
:center (the root center)
:orientation (alignment :front (rotate-vector-d (the (face-normal-vector :top))
-90
(the (face-normal-vector :front)))))
#+nil
(left-wing ;creates the left wing
:type 'wing-basic
:curve-in (the root-airfoil))
#+nil
(vert-tail ;creates the vertical tail
:type 'wing-basic
:curve-in (the root-airfoil))
#+nil
(rt-horz-tail ;creates the right horizontal tail
:type 'wing-basic
:curve-in (the tip-airfoil)
:orientation (alignment :rear
(rotate-vector-d (the (face-normal-vector :rear))
(the twist)
(the (face-normal-vector :top)))))
#+nil
(lt-horz-tail ;creates the vertical tail
:type 'wing-basic
:curve-in (the root-airfoil))))
| 2,200 | Common Lisp | .lisp | 70 | 25.342857 | 84 | 0.622307 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | f585e091f65ea76744605c4b6c16032d0d213e46f35615af22da6a8d64fc304a | 36,156 | [
-1
] |
36,157 | wing-example.lisp | lisp-mirror_gendl/documentation/training/g102/submissions/ccooper/source/wing-example.lisp | ;;; Wing exercise AE4-232
;;; 9 March 09
;;; Cory Cooper
;;;
;;; Help from Dave Cooper on 11 Mar 09
;;;
(in-package :gdl-user)
(define-object wing-basic (lofted-surface)
:input-slots
((root-chord 3)
(root-NACA-last-two 12)
(tip-NACA-last-two 12)
(wing-length 6)
(taper 0.5) ;ratio of tip chord/ root chord
(twist -10)) ;in degrees, negative indicates washout
:computed-slots
;;give the parent object the curves to loft between
((curves (list (the box-root-airfoil) (the box-tip-airfoil)))
(display-controls (list :color "#0000FF"
:isos (list :n-u 25 :n-v 10))))
:objects
((root-airfoil ;creates the root airfoil drawing aide
:type 'airfoil-basic
:chord (the root-chord)
:NACA-last-two (the root-NACA-last-two)
:center (the root center)
:orientation (the root orientation))
(tip-airfoil ;creates the tip airfoil drawing aide
:type 'airfoil-basic
:chord (* (the taper) (the root-chord))
:NACA-last-two (the tip-NACA-last-two)
:center (the root center)
:orientation (the root orientation))
(box-root-airfoil ;creates the boxed curve of the root airfoil
:type 'boxed-curve
:curve-in (the root-airfoil)) ;"made of this curve"
#+nil
(check-point :type 'point
:center (translate (the tip-airfoil top end)
:top (the wing-length)))
(box-tip-airfoil ;creates the boxed curve of the tip aifoil
:type 'boxed-curve
:curve-in (the tip-airfoil) ;"made of this curve"
;; move the curve out the length of the wing to loft to
:center
(translate (the center)
:top
(the wing-length)
)
:show-box? nil
;;move the box so that the twist angle rotates about the trailing edge axis
:orientation-center (translate (the center)
:right (- (the tip-airfoil chord)
(half (* (the tip-NACA-last-two)
0.01
(the tip-airfoil chord)))))
;;give the tip airfoil a twist
:orientation (alignment :rear
(rotate-vector-d (the (face-normal-vector :rear))
(the twist)
(the (face-normal-vector :top)))))))
#+nil
(define-object wing-reader (iges-reader)
:computed-slots ((file-name "/tmp/try.igs")))
| 2,359 | Common Lisp | .lisp | 64 | 29.765625 | 80 | 0.632194 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | ea11ad14faa8673fefcfa476a94d048cabd92810faad8ea13c1a8eaa125fde08 | 36,157 | [
-1
] |
36,158 | dependency-flag.lisp | lisp-mirror_gendl/documentation/training/g102/examples/dependency/source/dependency-flag.lisp | (in-package :gdl-user)
(define-object time-report ()
:computed-slots
((update-flag nil :settable)
(current-time-uncached (iso-8601-date (get-universal-time) :include-time? t) :uncached)
(current-time (progn (the update-flag)
(iso-8601-date (get-universal-time) :include-time? t)))))
#|
GDL-USER> (make-self 'time-report)
#<TIME-REPORT 4020123363>
GDL-USER> (the current-time)
"2015-06-12T16:34:20"
GDL-USER> (the current-time)
"2015-06-12T16:34:20"
GDL-USER> (the current-time)
"2015-06-12T16:34:20"
GDL-USER> (the (set-slot! :update-flag (not (the update-flag))))
NIL
GDL-USER> (the current-time)
"2015-06-12T16:34:41"
GDL-USER> (the current-time)
"2015-06-12T16:34:41"
GDL-USER> (the (set-slot! :update-flag (not (the update-flag))))
NIL
GDL-USER> (the current-time)
"2015-06-12T16:34:49"
GDL-USER> (the current-time)
"2015-06-12T16:34:49"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:53"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:53"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:54"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:55"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:56"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:57"
GDL-USER>
|#
| 1,243 | Common Lisp | .lisp | 42 | 27.928571 | 90 | 0.728956 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a51d5a0ff1183a75ae69b80450f0178a0b70dd8a1c465d4e6854d9fea89258fd | 36,158 | [
-1
] |
36,159 | primitives.lisp | lisp-mirror_gendl/documentation/training/g102/examples/solids/source/primitives.lisp | (in-package :gdl-user)
(define-object section-curve (base-object)
:objects
((surface :type 'surf::test-b-spline-surface)
(intersection-curve :type 'planar-section-curve
:plane-normal (the (face-normal-vector :top))
:plane-point (translate (the center)
:up 2))))
(define-object test-box (box-solid)
:input-slots
((length 10)
(width 10)
(height 20)
(display-controls (list :color :green
:transparency 0.5))
)
:hidden-objects
((hole :type 'cylinder-solid
:length (* (the length) 1.1)
:radius (half (half (the width)))))
:objects
(
(subtraction :type 'subtracted-solid
:brep self
:other-brep (the hole))
(vertex-spheres :type 'sphere
:display-controls (list :color :red)
:sequence (:size (the subtraction vertices
number-of-elements))
:center (the subtraction
(vertices (the-child index))
center)
:radius (/ (the length) 50))))
| 972 | Common Lisp | .lisp | 33 | 23.969697 | 54 | 0.64918 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 65c51c1095bd60f246ae567aed709ce766b82df538661fcbc2e3e3bc080cfba2 | 36,159 | [
-1
] |
36,160 | web-page.lisp | lisp-mirror_gendl/documentation/training/g102/examples/solids/source/web-page.lisp | (in-package :gwl-user)
(define-object surface-ui (base-html-graphics-sheet)
:hidden-objects
((b-spline-surface :type 'surf::test-b-spline-surface)
(view-object :type 'web-drawing
:objects (list (the b-spline-surface))
:projection-vector (getf *standard-views* :trimetric)
)))
(define-lens (html-format surface-ui)()
:output-functions
((main-sheet
()
(html (:html (:head (:title "Example of a Sectioned Surface"))
(:body (:p (the write-development-links))
(:h2 "Example of a Sectioned Surface")
(:p (:table
(:tr
((:td :bgcolor :yellow) "Surface Area")
(:td (:princ (number-round
(the b-spline-surface area) 3))))
))
(with-html-form ()
(:p (the write-geometry)))))))))
| 791 | Common Lisp | .lisp | 23 | 28 | 66 | 0.631507 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | f447b3504cb7d8d886f93c395d4450524150e3b9a24a7adbd03781de38e43cb4 | 36,160 | [
-1
] |
36,161 | assembly.lisp | lisp-mirror_gendl/documentation/training/g102/examples/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))))))
: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)))
: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))
(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"))))))))
| 4,294 | Common Lisp | .lisp | 109 | 32.862385 | 96 | 0.61488 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 67ccac9b219c849ce885b815a3dd024182c09908354e8811034f14f51969f698 | 36,161 | [
-1
] |
36,162 | building.lisp | lisp-mirror_gendl/documentation/training/g102/examples/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.
;;
(define-object building (box)
:input-slots (section proximity-rules)
:computed-slots
(;;
;; catch-all color for any non-specific buildings or building sub-types
;; with no color specified.
;;
(color :black)
(display-controls (list :color (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)))
(define-object proximity-rule ()
:input-slots (current-building neighbors target-type distance)
: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))))
;;
;;
;; FLAG -- fill in this value.
;;
;; 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 nil)))
| 3,438 | Common Lisp | .lisp | 85 | 35.529412 | 87 | 0.690643 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 454c95e982e47975a78a77d41e482a849c5f862540421fd5287544331ae3b63b | 36,162 | [
-1
] |
36,164 | simple-linkage.lisp | lisp-mirror_gendl/documentation/training/g102/examples/ackermann/source/simple-linkage.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 :ackermann)
(define-object simple-linkage (box)
:input-slots
(tie-rod-length
(kingpin-center (make-point 0 0 0))
(kingpin-radius 15)
(kingpin-inclination 10)
(kingpin-length 100)
(tie-rod-arm-length 300)
(tie-rod-arm-width 30)
(tie-rod-arm-height 30)
(tie-rod-arm-offset 50)
(current-rotation-angle 0)
(side :left)
(height (* (the kingpin-length) 1.25))
(width (* (the kingpin-diameter) 1.25))
(length (the width)))
:computed-slots
((kingpin-diameter (twice (the kingpin-radius)))
(kingpin-axis (the kingpin direction-vector))
(tie-rod-arm-ball-center (the tie-rod-arm ball-center))
(tie-rod-arm-vector (subtract-vectors (the tie-rod-arm-ball-center) (the tie-rod-arm-pivot-point)))
(straight-ahead-tie-rod-arm-ball-center (the straight-ahead-tie-rod-arm ball-center))
(tie-rod-arm-pivot-point (inter-line-plane
(the kingpin center) (the kingpin-axis)
(the straight-ahead-tie-rod-arm-ball-center) (the kingpin-axis)))
(straight-ahead-tie-rod-arm-vector (subtract-vectors (the straight-ahead-tie-rod-arm-ball-center)
(the tie-rod-arm-pivot-point))))
:objects
((kingpin :type 'cylinder
:radius (the kingpin-radius)
:center (the kingpin-center)
:length (the kingpin-length)
:orientation (alignment :front
(rotate-vector-d (the (face-normal-vector :top)) (the kingpin-inclination)
(the (face-normal-vector (the side))))))
(tie-rod-arm :type 'tie-rod-arm
:kingpin-center (the kingpin center)
:kingpin-axis (the kingpin-axis)
:front-vector (the (face-normal-vector :left))
:length (the tie-rod-arm-length)
:width (the tie-rod-arm-width)
:height (the tie-rod-arm-height)
:offset (the tie-rod-arm-offset)
:current-rotation-angle (the current-rotation-angle)))
:hidden-objects
((straight-ahead-tie-rod-arm :type 'tie-rod-arm
:kingpin-center (the kingpin center)
:kingpin-axis (the kingpin-axis)
:front-vector (the (face-normal-vector :left))
:length (the tie-rod-arm-length)
:width (the tie-rod-arm-width)
:height (the tie-rod-arm-height)
:offset (the tie-rod-arm-offset)
:current-rotation-angle 0)
(tie-rod-ball-socket-sphere :type 'sphere
:center (the tie-rod-arm ball-center)
:radius (the tie-rod-length))
(tie-rod-arm-ball-articulation-circle :type 'circle
:radius (half (the tie-rod-arm length))
:center (inter-line-plane (the kingpin center)
(the kingpin-axis)
(the straight-ahead-tie-rod-arm-ball-center)
(the kingpin-axis))
:orientation (alignment :top (the kingpin direction-vector)))))
| 3,581 | Common Lisp | .lisp | 85 | 37.258824 | 102 | 0.693544 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | d28e89fb2a1140bc644398bae335bf89e8d99ad60f3e6813273455048764a3bf | 36,164 | [
-1
] |
36,165 | package.lisp | lisp-mirror_gendl/documentation/training/g102/examples/ackermann/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/>.
;;
(gwl:define-package :ackermann (:export #:assembly))
| 912 | Common Lisp | .lisp | 21 | 42.142857 | 70 | 0.76153 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | f99f8b27a41483b221547c86952c3afd87b26ce1f2fb2995ce25eb787196d3ad | 36,165 | [
-1
] |
36,166 | ackermann-assembly.lisp | lisp-mirror_gendl/documentation/training/g102/examples/ackermann/source/ackermann-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 :ackermann)
(define-object assembly (box)
:documentation (:description "Schematic of a typical truck steering system.")
:input-slots
(("List of 3D points. Enabled 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-spec (list :left 30)))
:computed-slots
((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 (ecase (first (the current-rotation-angle-spec))
(:left 0) (:right 1)))))
(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))
;;
;; FLAG -- compute this based on intersection of sphere and 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 kingpin-axis)
(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) (first (the current-rotation-angle-spec)))
(second (the current-rotation-angle-spec))
(the other-tie-rod-rotation)))))
| 3,535 | Common Lisp | .lisp | 80 | 39.6625 | 98 | 0.710611 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | c41d4149d6bf09fec7c1338d74c1f0782dd3194473b23e4f074b14b44c98a3b5 | 36,166 | [
-1
] |
36,167 | tie-rod-arm.lisp | lisp-mirror_gendl/documentation/training/g102/examples/ackermann/source/tie-rod-arm.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 :ackermann)
(define-object tie-rod-arm (box)
:input-slots
(kingpin-center
kingpin-axis
front-vector
offset
current-rotation-angle
(ball-radius 20))
:computed-slots
((center (translate-along-vector (the kingpin-center) (the kingpin-axis) (the offset)))
(orientation (alignment :top (the kingpin-axis) :front
(rotate-vector-d (the front-vector) (the current-rotation-angle)
(the kingpin-axis))))
(ball-center (the (face-center :rear))))
:objects
((ball :type 'sphere
:radius (the ball-radius)
:center (the ball-center))
(pipe :type 'c-cylinder
:radius (half (the width))
:start (the center)
:end (the ball center))))
| 1,551 | Common Lisp | .lisp | 43 | 33.418605 | 89 | 0.730539 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 5301f8b661e11268f2275681e890500f852894233e49ef94d96ee51bb32219dc | 36,167 | [
-1
] |
36,168 | t-support.lisp | lisp-mirror_gendl/documentation/training/g102/examples/table/source/t-support.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)
(define-object t-support-1 (box)
:input-slots
(cost-per-inch
(length 120)
)
:computed-slots
((height (/ (the width) 2))
(width 12)
(support-thickness 2)
(cost (* (the length) (the cost-per-inch))))
:objects
((vertical-support :type 'box
:center (translate (the center)
:down
(half (the-child height)))
:width (the support-thickness)
:height (the height)
:length (the length))
(horizontal-support :type 'box
:center (translate (the center)
:up
(half (the-child height)))
:width (the width)
:length (the length)
:height (the support-thickness))))
| 1,579 | Common Lisp | .lisp | 46 | 29.891304 | 70 | 0.690873 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | c5328d889a3ae783641f550adcead025459a7114881161831fff8b2301c0aa37 | 36,168 | [
-1
] |
36,169 | table.lisp | lisp-mirror_gendl/documentation/training/g102/examples/table/source/table.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)
(define-object table (box)
:input-slots
((leg-type 't-support-1)
(length 50)
(width 70)
(height 20 :settable)
(top-thickness 1/2)
(number 2 :settable)
)
:objects
((table-top :type 'box
:length (the length)
:width (the width)
:height (the top-thickness))
(legs :type (the leg-type)
:length (the height)
:width 2
:height 3
:orientation (alignment (ecase (first (the-child index))
(1 :bottom)
(0 :top))
(the (face-normal-vector :rear)))
:center (translate (the center)
(ecase (second (the-child index))
(0 :right)
(1 :left))
(- (half (the width)) (half (the-child width)))
(ecase (first (the-child index))
(0 :rear)
(1 :front))
(- (half (the length))
(half (the-child height)))
:down (+ (half (the top-thickness))
(half (the-child length))))
:sequence (:matrix :longitudinal (the number) :lateral (the number)))))
| 1,917 | Common Lisp | .lisp | 56 | 29.196429 | 73 | 0.6617 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | c68fdfe95d6dd028fa466965f70d132a85c2e088d10a4b6c61fb27038ed7d934 | 36,169 | [
-1
] |
36,170 | fuselage-example.lisp | lisp-mirror_gendl/documentation/training/g102/examples/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)
(setq *brep-isos-default* '(:n-u 8 :n-v 8))
(define-object fuselage-cylinder (cylinder-solid)
:input-slots
((length 10)
(radius 5)))
(define-object fuselage-cone (cone-solid)
:input-slots
((length 7)
(radius-1 5)
(radius-2 3)))
| 1,171 | Common Lisp | .lisp | 31 | 34.774194 | 71 | 0.722124 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a324fc349030dc476be301ed3d88d19b8954b4fea66d46283ea1ce139a4ae4af | 36,170 | [
-1
] |
36,171 | tower-example.lisp | lisp-mirror_gendl/documentation/training/g102/examples/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-box (base-object)
:input-slots ((length 10)
(width 20)
(height 15))
:objects
((brick :type 'box)))
(define-object tower-boxes (base-object)
:input-slots ((length 10)
(width 20)
(height 15)
(number-of-bricks 25))
:objects
((bricks :type 'box
:sequence (:size (the number-of-bricks)))))
(define-object stacked-boxes (base-object)
:input-slots ((length 10)
(width 20)
(height 15)
(number-of-bricks 25)
)
:computed-slots
((tower-height (* (the number-of-bricks) (the height)))
(tower-height-measured (3d-distance (the (bricks 0) (face-center :bottom))
(the bricks last (face-center :top)))))
:objects
((bricks :type 'box
:sequence (:size (the number-of-bricks))
:center (translate (the center) :up (* (the-child height)
(the-child index))))))
(define-object twisted-stacked-boxes (base-object)
:input-slots ((length 10)
(width 20)
(height 15)
(number-of-bricks 25)
(twist-degrees 5))
:computed-slots
((tower-height (* (the number-of-bricks) (the height)))
(tower-height-measured (3d-distance (the (bricks 0) (face-center :bottom))
(the bricks last (face-center :top))))
(total-volume (apply #'+ (list-elements (the bricks) (the-element volume)))))
:objects
((bricks :type 'box
:sequence (:size (the number-of-bricks))
:orientation (alignment :rear (rotate-vector-d (the (face-normal-vector :rear))
(* (the-child index) (the twist-degrees))
(the (face-normal-vector :top))))
:center (translate (the center) :up (* (the-child height)
(the-child index))))))
| 2,564 | Common Lisp | .lisp | 69 | 33.101449 | 83 | 0.691834 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 0f421331c25c5d2247cdd8f4a968ffc72eaf2b8b78d03ed306ca39b2a81cbb7d | 36,171 | [
-1
] |
36,172 | section-2-examples.lisp | lisp-mirror_gendl/documentation/training/g102/examples/source/section-2-examples.lisp | ;;
;; Copyright 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-g102)
(defun square (number)
(* number number))
(define-object speed-of-sound ()
:computed-slots ((gamma 7/5)
(R 8.3145)
(M 0.0289645)
(temperature 273)
(speed (sqrt (* (the gamma) (the R)
(the M) (the temperature))))))
(define-object speed-of-sound-at-temperature ()
:input-slots (temperature)
:computed-slots ((gamma 7/5)
(R 8.3145)
(M 0.0289645)
(speed (sqrt (* (the gamma) (the R)
(the M) (the temperature))))))
(define-object speeds-of-sound ()
:computed-slots ((average-speed
(/ (+ (the cold-speed speed)
(the warm-speed speed)
(the hot-speed speed)) 3)))
:objects ((cold-speed :type 'speed-of-sound-at-temperature
:temperature 242)
(warm-speed :type 'speed-of-sound-at-temperature
:temperature 288)
(hot-speed :type 'speed-of-sound-at-temperature
:temperature 320)))
(define-object speeds-of-sound-sequence ()
:computed-slots ((temperatures (list 242 288 320))
(average-speed
(/ (apply #'+
(mapcar #'(lambda(speed)
(the-object speed speed))
(list-elements (the speeds))))
(the speeds number-of-elements)))
(average-speed-shorter
(/ (sum-elements (the speeds) (the-element speed))
(the speeds number-of-elements))))
:objects ((speeds :type 'speed-of-sound-at-temperature
:sequence (:size (length (the temperatures)))
:temperature (nth (the-child index) (the temperatures)))))
(define-object speed-of-sound-at-temperature-func ()
:computed-slots ((gamma 7/5)
(R 8.3145)
(M 0.0289645))
:functions ((speed
(temperature)
(sqrt (* (the gamma) (the R) (the M) temperature)))))
(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))))
(define-object wing-surface-and-volume (base-ajax-sheet)
:computed-slots
((main-sheet-body
(with-cl-who-string ()
(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-cl-who-string ()
(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-cl-who-string ()
(:p (str (the span html-string)))))
(report-section
:type 'sheet-section
:inner-html (with-cl-who-string ()
((: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-cl-who-string ()
(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-cl-who-string ()
(: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-cl-who-string ()
(: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-cl-who-string ()
(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-cl-who-string ()
(: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))))
#+nil
(define-object city (box)
:input-slots
((length 10)
(width 10)
(height 0.25)
(max-allowed-daily-water-usage 5000)
(building-1-data '(:type bank :height 30 :width 70 :length 50))
(building-2-data '(:type hotel :height 100 :width 40 :length 30)))
:computed-slots
((total-daily-water-usage
(+ (the building-1 daily-water-usage)
(the building-2 daily-water-usage)))
(too-much-water-usage?
(> (the total-daily-water-usage) (the max-allowed-daily-water-usage))))
:objects
((building-1 :type (getf (the building-1-data) :type)
:height (getf (the building-1-data) :height)
:width (getf (the building-1-data) :width)
:length (getf (the building-1-data) :length))
(building-2 :type (getf (the building-2-data) :type)
:height (getf (the building-2-data) :height)
:width (getf (the building-2-data) :width)
:length (getf (the building-2-data) :length))))
#+nil
(define-object city-2 (box)
:input-slots
((length 10)
(width 10)
(height 0.25)
(max-allowed-daily-water-usage 5000)
(building-1-data '(:type bank :height 30 :width 70 :length 50))
(building-2-data '(:type hotel :height 100 :width 40 :length 30)))
:computed-slots
((total-daily-water-usage (+ (the building-1 daily-water-usage) (the building-2 daily-water-usage)))
(too-much-water-usage? (> (the total-daily-water-usage) (the max-allowed-daily-water-usage))))
:objects
((:building-1 :type (getf (the building-1-data) :type)
:parameters (rest (rest (the building-1-data))))
(:building-2 :type (getf (the building-2-data) :type)
:parameters (rest (rest (the building-2-data))))))
#+nil
(define-object city-3 (box)
:input-slots
((length 10)
(width 10)
(height 0.25)
(max-allowed-daily-water-usage 5000)
(building-data '((:type bank :height 30 :width 70 :length 50)
(:type hotel :height 100 :width 40 :length 30))))
:computed-slots
((total-daily-water-usage
(apply #'+ (list-elements (the buildings) (the-element daily-water-usage))))
(too-much-water-usage?
(> (the total-daily-water-usage) (the max-allowed-daily-water-usage))))
:objects
((:buildings :type (:sequence (mapcar #'(lambda (plist) (getf plist :type))
(the building-data)))
:sequence (:size (length (the building-data)))
:parameters (rest (rest (nth (the-child index) (the building-data)))))))
#+nil
(defparameter *city-data*
`(:buildings
((:type bank :height 30 :width 70 :length 50 :center ,(make-point 50 50 15))
(:type hotel :height 100 :width 40 :length 30 :center ,(make-point -50 -50 50)))))
#+nil
(define-object city-4 (box)
:input-slots
((length 200)
(width 200)
(height 10)
(max-allowed-daily-water-usage 5000)
(building-data (getf *city-data* :buildings)))
:computed-slots
((display-controls (list :color :blue :transparency 0.5)))
:objects
((:buildings :type (:sequence (mapcar #'(lambda (plist) (getf plist :type)) (the building-data)))
:sequence (:size (length (the building-data)))
:center (getf (nth (the-child index) (the building-data)) :center)
:parameters (rest (rest (nth (the-child index) (the building-data)))))))
#+nil
(define-object building (box))
#+nil
(define-object bank (building)
:computed-slots
((daily-water-usage 2000)))
#+nil
(define-object hotel (building)
:computed-slots
((daily-water-usage 4000)))
| 38,524 | Common Lisp | .lisp | 889 | 29.283465 | 102 | 0.516037 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 51993f193df870f7dc9a5f35a914e79871ed65bb90bce85a56ffe5c4426cfd3e | 36,172 | [
-1
] |
36,173 | drawing.lisp | lisp-mirror_gendl/documentation/training/g102/examples/source/drawing.lisp | (in-package :gdl-user)
(define-object robot-drawing (base-drawing)
:hidden-objects ((robot-assembly :type 'robot:assembly)
(text-block :type 'robot-text-block
:margins (twice (twice (the text-view left-margin)))
:width (the text-view width)
:length (the text-view length)
:robot-width (the robot-assembly height)
:robot-length (the robot-assembly length)
:arm-angle-left (the robot-assembly arm-angle-left)
:head-angle (the robot-assembly head-angle)
:body-angle (the robot-assembly body-angle)))
:objects
((text-view :type 'base-view
;;:left-margin 0
;;:front-margin 0
:border-box? t
:objects (list (the text-block))
:length (half (the length))
:width (half (the width))
:projection-vector (getf *standard-views* :top)
:center (translate (the center) :rear (half (the-child length))
:right (half (the-child width))))
(tri-view :type 'base-view
:border-box? t
:object-roots (list (the robot-assembly robot))
:length (half (the length))
:width (half (the width))
:center (translate (the center) :rear (half (the-child length))
:left (half (the-child width)))
:projection-vector (getf *standard-views* :trimetric))
(top-view :type 'base-view
:border-box? t
:object-roots (list (the robot-assembly robot))
:annotation-objects (list (the top-width-dim)
(the top-length-dim))
:view-scale (* 0.80 (getf (the-child view-contents-data) :view-scale))
:length (half (the length))
:width (half (the width))
:center (translate (the center) :front (half (the-child length))
:left (half (the-child width)))
:projection-vector (getf *standard-views* :top))
(top-width-dim :type 'horizontal-dimension
:character-size 10
:dim-scale (/ (the top-view view-scale))
:witness-line-length 20
:witness-line-gap 70
:witness-line-ext 5
:start-point (the top-view (view-point (the robot-assembly robot body (arms 0) (vertex :rear :left :top))))
:end-point (the top-view (view-point (the robot-assembly robot body (arms 1) (vertex :rear :right :top)))))
(top-length-dim :type 'vertical-dimension
:dim-scale (/ (the top-view view-scale))
:character-size 10
:witness-line-length 15
:witness-line-gap 25
:witness-line-ext 3
:flip-leaders? t
:start-point (the top-view (view-point (the robot-assembly robot body base foot (vertex :rear :left :top))))
:end-point (the top-view (view-point (the robot-assembly robot body base foot (vertex :front :left :top)))))
(front-view :type 'base-view
:border-box? t
:object-roots (list (the robot-assembly robot))
:length (half (the length))
:width (half (the width))
:center (translate (the center) :front (half (the-child length))
:right (half (the-child width)))
:projection-vector (getf *standard-views* :front))
))
(define-object robot-text-block (typeset-block)
:input-slots
(robot-width robot-length body-angle arm-angle-left head-angle margins)
:functions
((content
()
(tt:compile-text (:font "Helvetica" :font-size 12.0)
(tt:vspace 100)
(tt:paragraph () "Robot Data")
(let ((width (- (the width) (the margins))))
(tt:table (:col-widths (list (* 2/3 width) (* 1/3 width)))
(dolist (slot (list :robot-width :robot-length :body-angle :arm-angle-left :head-angle))
(tt:row ()
(tt:cell (:background-color "#00FF00") (tt:put-string (format nil "~a" (string-capitalize slot))))
(tt:cell ()
(tt:paragraph (:h-align :center) (tt:put-string (format nil "~a" (the (evaluate slot))))))))))))))
| 3,789 | Common Lisp | .lisp | 84 | 38.261905 | 113 | 0.639161 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 15b2a7658db943cd1650065106dfe811cac1a9cc3c80195c0750955bcec6c640 | 36,173 | [
-1
] |
36,174 | hairy.lisp | lisp-mirror_gendl/documentation/training/g102/examples/source/hairy.lisp | ;;
;; Copyright 20012 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-g102)
(defun square (number)
(* number number))
(define-object speed-of-sound ()
:computed-slots ((gamma 7/5)
(R 8.3145)
(M 0.0289645)
(temperature 273)
(speed (sqrt (* (the gamma) (the R)
(the M) (the temperature))))))
(define-object speed-of-sound-at-temperature ()
:input-slots (temperature)
:computed-slots ((gamma 7/5)
(R 8.3145)
(M 0.0289645)
(speed (sqrt (* (the gamma) (the R)
(the M) (the temperature))))))
(define-object speeds-of-sound ()
:computed-slots ((average-speed
(/ (+ (the cold-speed speed)
(the warm-speed speed)
(the hot-speed speed)) 3)))
:objects ((cold-speed :type 'speed-of-sound-at-temperature
:temperature 242)
(warm-speed :type 'speed-of-sound-at-temperature
:temperature 288)
(hot-speed :type 'speed-of-sound-at-temperature
:temperature 320)))
(define-object speeds-of-sound-sequence ()
:computed-slots ((temperatures (list 242 288 320))
(average-speed
(/ (apply #'+
(mapcar #'(lambda(speed)
(the-object speed speed))
(list-elements (the speeds))))
(the speeds number-of-elements)))
(average-speed-shorter
(/ (sum-elements (the speeds) (the-element speed))
(the speeds number-of-elements))))
:objects ((speeds :type 'speed-of-sound-at-temperature
:sequence (:size (length (the temperatures)))
:temperature (nth (the-child index) (the temperatures)))))
(define-object speed-of-sound-at-temperature-func ()
:computed-slots ((gamma 7/5)
(R 8.3145)
(M 0.0289645))
:functions ((speed
(temperature)
(sqrt (* (the gamma) (the R) (the M) temperature)))))
(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))))
(define-object wing-surface-and-volume (base-ajax-sheet)
:computed-slots
((main-sheet-body
(with-cl-who-string ()
(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-cl-who-string ()
(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-cl-who-string ()
(:p (str (the span html-string)))))
(report-section
:type 'sheet-section
:inner-html (with-cl-who-string ()
((: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-cl-who-string ()
(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-cl-who-string ()
(: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-cl-who-string ()
(: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-cl-who-string ()
(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-cl-who-string ()
(: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))))
#+nil
(define-object city (box)
:input-slots
((length 10)
(width 10)
(height 0.25)
(max-allowed-daily-water-usage 5000)
(building-1-data '(:type bank :height 30 :width 70 :length 50))
(building-2-data '(:type hotel :height 100 :width 40 :length 30)))
:computed-slots
((total-daily-water-usage
(+ (the building-1 daily-water-usage)
(the building-2 daily-water-usage)))
(too-much-water-usage?
(> (the total-daily-water-usage) (the max-allowed-daily-water-usage))))
:objects
((building-1 :type (getf (the building-1-data) :type)
:height (getf (the building-1-data) :height)
:width (getf (the building-1-data) :width)
:length (getf (the building-1-data) :length))
(building-2 :type (getf (the building-2-data) :type)
:height (getf (the building-2-data) :height)
:width (getf (the building-2-data) :width)
:length (getf (the building-2-data) :length))))
#+nil
(define-object city-2 (box)
:input-slots
((length 10)
(width 10)
(height 0.25)
(max-allowed-daily-water-usage 5000)
(building-1-data '(:type bank :height 30 :width 70 :length 50))
(building-2-data '(:type hotel :height 100 :width 40 :length 30)))
:computed-slots
((total-daily-water-usage (+ (the building-1 daily-water-usage) (the building-2 daily-water-usage)))
(too-much-water-usage? (> (the total-daily-water-usage) (the max-allowed-daily-water-usage))))
:objects
((:building-1 :type (getf (the building-1-data) :type)
:parameters (rest (rest (the building-1-data))))
(:building-2 :type (getf (the building-2-data) :type)
:parameters (rest (rest (the building-2-data))))))
#+nil
(define-object city-3 (box)
:input-slots
((length 10)
(width 10)
(height 0.25)
(max-allowed-daily-water-usage 5000)
(building-data '((:type bank :height 30 :width 70 :length 50)
(:type hotel :height 100 :width 40 :length 30))))
:computed-slots
((total-daily-water-usage
(apply #'+ (list-elements (the buildings) (the-element daily-water-usage))))
(too-much-water-usage?
(> (the total-daily-water-usage) (the max-allowed-daily-water-usage))))
:objects
((:buildings :type (:sequence (mapcar #'(lambda (plist) (getf plist :type))
(the building-data)))
:sequence (:size (length (the building-data)))
:parameters (rest (rest (nth (the-child index) (the building-data)))))))
#+nil
(defparameter *city-data*
`(:buildings
((:type bank :height 30 :width 70 :length 50 :center ,(make-point 50 50 15))
(:type hotel :height 100 :width 40 :length 30 :center ,(make-point -50 -50 50)))))
#+nil
(define-object city-4 (box)
:input-slots
((length 200)
(width 200)
(height 10)
(max-allowed-daily-water-usage 5000)
(building-data (getf *city-data* :buildings)))
:computed-slots
((display-controls (list :color :blue :transparency 0.5)))
:objects
((:buildings :type (:sequence (mapcar #'(lambda (plist) (getf plist :type)) (the building-data)))
:sequence (:size (length (the building-data)))
:center (getf (nth (the-child index) (the building-data)) :center)
:parameters (rest (rest (nth (the-child index) (the building-data)))))))
#+nil
(define-object building (box))
#+nil
(define-object bank (building)
:computed-slots
((daily-water-usage 2000)))
#+nil
(define-object hotel (building)
:computed-slots
((daily-water-usage 4000)))
| 38,525 | Common Lisp | .lisp | 889 | 29.284589 | 102 | 0.516051 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 5fc28efe273f3017f1595993da5bb52f36471fbd17bb8572ca2fdd55b4eec8a8 | 36,174 | [
-1
] |
36,176 | g102-exercises.lisp | lisp-mirror_gendl/documentation/training/g102/examples/source/g102-exercises.lisp | ;;
;; Copyright 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)
(define-object lift-calculator ()
:input-slots
(rho v A C-of-L)
:computed-slots
(;;
;; FLAG -- wrong
;; replace with
;; correct expression
;;
(lift (* (the rho) (the v) (the A) (the C-of-L)))
;;
))
(define-object lift-forces ()
:input-slots
((data-plists (list (list :rho 1.22 :v 108 :A 25 :C-of-L 0.2)
(list :rho 1.22 :v 123 :A 38 :C-of-L 0.2)
(list :rho 1.22 :v 142 :A 42 :C-of-L 0.2))))
:objects
((lift-calculators :type 'lift-calculator
:sequence (:size (length (the data-plists)))
:rho (getf (nth (the-child index) (the data-plists)) :rho)
:v (getf (nth (the-child index) (the data-plists)) :v)
:A (getf (nth (the-child index) (the data-plists)) :A)
:C-of-L (getf (nth (the-child index) (the data-plists)) :C-of-G))))
(define-object lift-forces-alternative ()
:input-slots
((data-plists (list (list :rho 1.22 :v 108 :A 25 :C-of-L 0.2)
(list :rho 1.22 :v 123 :A 38 :C-of-L 0.2)
(list :rho 1.22 :v 142 :A 42 :C-of-L 0.2))))
:objects
((lift-calculators :type 'lift-calculator
:sequence (:size (length (the data-plists)))
:parameters (the data-plists))))
(define-object lift-calculator-with-func ()
:input-slots
(rho v A)
:functions
((lift
(C-of-L)
;; FLAG -- wrong
;; replace with
;; correct expression
;;
(* (the rho) (the v) (the A) C-of-L))))
| 2,323 | Common Lisp | .lisp | 65 | 31.338462 | 93 | 0.638468 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 3e865cc5555c1862e9dc58938a0aec9fca3e9041f444f922bfb47b82f1fa65b7 | 36,176 | [
-1
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.