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
37,735
protocol.lisp
open-rsx_rsbag-cl/src/rsb/protocol.lisp
;;;; protocol.lisp --- Protocol functions used in the rsb module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb) ;;; Connection setup protocol (defgeneric events->bag (source dest &rest args &key error-policy transports filters timestamp if-exists backend bag-class channel-strategy start? &allow-other-keys) (:argument-precedence-order dest source) (:documentation "Make and return a connection between the RSB participant(s) SOURCE and the channel or bag DEST. When the connection is established, events received by SOURCE are stored in DEST. The keyword arguments ARGS are passed to the function constructing SOURCE, the function constructing DEST or the new connection depending on their keyword part. If supplied, ERROR-POLICY has to be nil or a function to be called with a `condition' object when an error is signaled. If supplied, TRANSPORTS configures RSB transport mechanisms. See `rsb:make-participant' for details. FILTERS is a list of RSB filters (which can be ordinary functions) that are applied to discriminate events for recording. Only events matching all elements of FILTERS are recorded. If supplied, TIMESTAMP has to be a keyword and selects the RSB event timestamp that should be used for indexing the recorded events. Canonical RSB timestamp names are :create, :send, :receive and :deliver, but other user provided timestamp can be used as well. IF-EXISTS specifies the behavior DEST already exists. Valid values are :error and :overwrite. See `rsbag:open-bag' for more information. BACKEND can be used to explicitly select a file-format backend for DEST. If supplied, it has to be a keyword designating a file-format backend. Available backends can be inspected using the service designated by `rsbag.backend:backend'. If supplied, BAG-CLASS selects the class of the bag created for DEST. Note that a bag class capable of handling concurrent accesses has to be selected if SOURCE amounts to multiple sources. If supplied, CHANNEL-STRATEGY selects a channel allocation strategy which is responsible for adding channels to DEST when events cannot be stored in any of the existing channels. Available backends can be inspected using the service designated by `rsbag.rsb:channel-strategy'. If supplied, START? controls whether the recording should start immediately. The default behavior is to start immediately.")) (defgeneric bag->events (source dest &rest args &key error-policy backend bag-class replay-strategy start-time start-index end-time end-index channels filters &allow-other-keys) (:documentation "Make and return a connection between the channel or bag SOURCE and the RSB participant(s) DEST. When the connection is established, events are read from SOURCE and published via DEST. The keyword arguments ARGS are passed to the function constructing DEST, the function constructing SOURCE or the new connection depending on their keyword part. If supplied, ERROR-POLICY has to be nil or a function to be called with a `condition' object when an error is signaled. BACKEND can be used to explicitly select a file-format backend for SOURCE. If supplied, it has to be a keyword designating a file-format backend. Available backends can be inspected using the service designated by `rsbag.backend:backend'. If supplied, BAG-CLASS selects the class of the bag created for SOURCE. See `rsbag:open-bag'. If supplied, REPLAY-STRATEGY selects a replay strategy that controls the replay timing and coordinates the publishing of events via informers. START-INDEX and END-INDEX can be used to select a range of stored events for replay. The default behavior consists in replaying all stored events. Similarly, START-TIME and END-TIME can be used to select a range of stored events for replay based on temporal bounds. Note that the actual start and end of the replay correspond to the events in SOURCE which are closest to START-TIME and END-TIME respectively. Times can be specified as `local-time:timestamp' instances and real numbers. The latter are treated as offsets from the start of the recorded date when non-negative and from the end of the recorded data when negative. If supplied, CHANNELS selects a subset of channels from which events should be replayed. If supplied, FILTERS is a list of RSB filters that events have to match in order to be replayed.")) ;;; Connection protocol (defgeneric connection-bag (connection) (:documentation "Return the associated bag of CONNECTION.")) (defgeneric done? (connection) (:documentation "Return non-nil, if CONNECTION has finished transferring events from its source to its destination.")) (defgeneric wait (connection) (:documentation "Wait until CONNECTION finishes transferring events from its source to its destination, then return.")) (defgeneric start (connection) (:documentation "Start recording events received by the associated participant of CONNECTION into the associated bag of CONNECTION. Recording can be stopped temporarily using the `stop' function or permanently using `close'.")) (defgeneric stop (connection) (:documentation "Stop recording events received by the associated participant of CONNECTION into the associated bag of CONNECTION. Recording can be continue using the `start' function.")) ;; connections also implement a method on cl:close ;;; Composite connection protocol (defgeneric connection-direct-connections (connection) (:documentation "Return the direct child connections of CONNECTION.")) (defgeneric connection-connections (connection &key include-inner? include-self? leaf-test) (:documentation "Return a list of certain ancestor connections of CONNECTION. INCLUDE-INNER? controls whether inner nodes or only leafs of the connection tree are returned. INCLUDE-SELF? controls whether CONNECTION is returned. LEAF-TEST is a predicate that is called to determine whether a given connection should be considered a leaf or an inner node.")) ;; Default behavior (defmethod connection-direct-connections ((connection t)) '()) (defmethod connection-connections ((connection t) &key (include-inner? t) (include-self? include-inner?) (leaf-test (of-type 'channel-connection))) (let ((connections (mappend (rcurry #'connection-connections :include-inner? include-inner?) (connection-direct-connections connection)))) (cond (include-self? (list* connection connections)) ((funcall leaf-test connection) (list connection)) (t connections))))
7,860
Common Lisp
.lisp
162
38.777778
82
0.672236
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ca2617f3c24f5223659298b677ab4a291c40391508d6d5b4a8efa360710ffc58
37,735
[ -1 ]
37,736
bag-connection.lisp
open-rsx_rsbag-cl/src/rsb/bag-connection.lisp
;;;; bag-connection.lisp --- A class for bag <-> RSB connections. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb) ;;; `composite-connection-mixin' class (defclass composite-connection-mixin () ((connections :initarg :connections :type list #|of connections|# :reader connection-direct-connections :initform '() :documentation "Stores a list of child connections.")) (:documentation "Intended to be mixed into connection classes with child connections.")) (defmethod shared-initialize :after ((instance composite-connection-mixin) (slot-names t) &key) (setf (rsb.ep:processor-error-policy instance) (rsb.ep:processor-error-policy instance))) (defmethod (setf rsb.ep:processor-error-policy) :before ((new-value t) (object composite-connection-mixin)) (iter (for connection in (connection-direct-connections object)) (setf (rsb.ep:processor-error-policy connection) new-value))) (defmethod close ((connection composite-connection-mixin) &key abort) ;; Close all direct child connections. (map nil (rcurry #'close :abort abort) (connection-direct-connections connection))) (defmethod wait ((connection composite-connection-mixin)) (map nil #'wait (connection-direct-connections connection))) (defmethod start ((connection composite-connection-mixin)) (map nil #'start (connection-direct-connections connection))) (defmethod stop ((connection composite-connection-mixin)) (map nil #'stop (connection-direct-connections connection))) (defmethod print-items:print-items append ((object composite-connection-mixin)) `((:direct-connection-count ,(length (connection-direct-connections object)) "(~D)"))) ;;; `bag-connection' class (defclass bag-connection (composite-connection-mixin rsb.ep:error-policy-mixin print-items:print-items-mixin) ((bag :initarg :bag :reader connection-bag :documentation "Stores the bag object that is connected to the data source(s) or sink(s).")) (:default-initargs :bag (missing-required-initarg 'bag-connection :bag)) (:documentation "Connections between channels of bags and data sources or sinks.")) (defmethod close ((connection bag-connection) &key abort) (call-next-method) (close (connection-bag connection) :abort abort)) ;;; `recording-bag-connection' class (defclass recording-bag-connection (bag-connection) ((introspection-survey? :initarg :introspection-survey? :reader connection-introspection-survey? :initform t :documentation "Controls whether the connection should perform an RSB introspection survey when the recording is started.")) (:documentation "Instances of this class are used to record events into a bag.")) (defmethod start :after ((connection recording-bag-connection)) ;; After the recording has been started, perform an introspection ;; survey, recording the introspection replies. This inserts an ;; introspection snapshot at the beginning of the recording in ;; relation to which the differential introspection information in ;; the remainder of the recording can be interpreted. (when (connection-introspection-survey? connection) (log:info "~@<~A is performing introspection survey.~@:>" connection) (restart-case ;; TODO the transport should normalize this (let+ (((&flet normalize-url (url) (puri:copy-uri url :path nil :parsed-path nil :fragment nil))) (urls (mapcar #'normalize-url (mappend (compose #'rsb:transport-specific-urls #'connection-endpoint) (connection-connections connection :include-inner? nil)))) (urls (remove-duplicates urls :test #'puri:uri=))) (rsb:with-participant (introspection :remote-introspection rsb.introspection:+introspection-scope+ :receiver-uris urls :update-interval nil :error-policy #'continue) (declare (ignore introspection)))) (continue () :report (lambda (stream) (format stream "~@<Continue recording using ~A ~ without an introspection ~ survey.~@:>" connection))))))
4,921
Common Lisp
.lisp
97
39.051546
80
0.617928
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
534430245b451b7b34572c988a628294b72272003d0ab2fa7ff179215426a71d
37,736
[ -1 ]
37,737
conditions.lisp
open-rsx_rsbag-cl/src/rsb/conditions.lisp
;;;; conditions.lisp --- Conditions used in the rsb module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb) (define-condition connection-condition (rsbag-condition) ((connection :initarg :connection :reader connection-condition-connection :documentation "Stores the connection involved in the condition.")) (:default-initargs :connection (missing-required-initarg 'connection-condition :connection)) (:documentation "Subclasses of this condition are signaled when a bag connection is involved.")) (define-condition entry-condition (rsbag-condition) ((entry :initarg :entry :reader entry-condition-entry :documentation "Stores the entry involved in the condition.")) (:default-initargs :entry (missing-required-initarg 'entry-condition :entry)) (:documentation "Subclasses of this conditions are signaled when a bag entry is involved."))
1,047
Common Lisp
.lisp
26
35.038462
76
0.708251
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
77d5d65572d2eed0f3f2989213d6d2472f2ef08ae572390e2bc2ab720548111d
37,737
[ -1 ]
37,738
macros.lisp
open-rsx_rsbag-cl/src/rsb/macros.lisp
;;;; macros.lisp --- Macros provided by the rsb module. ;;;; ;;;; Copyright (C) 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb) (defmacro with-open-connection ((var connection-form) &body body) "Execute BODY with VAR bound to the connection object that is the result of evaluating CONNECTION-FORM. Ensure that the connection is properly closed." `(with-open-stream (,var ,connection-form) ,@body)) (defmacro with-events->bag ((var source dest &rest args &key error-policy transports filters timestamp backend bag-class channel-strategy &allow-other-keys) &body body) "Execute BODY with VAR bound to a connection that is the result of applying `events->bag' to SOURCE, DEST and ARGS. Ensure that the resulting connection is properly closed." (declare (ignore error-policy transports filters timestamp backend bag-class channel-strategy)) `(with-open-connection (,var (events->bag ,source, dest ,@args)) ,@body)) (defmacro with-bag->events ((var source dest &rest args &key error-policy backend bag-class replay-strategy start-time start-index end-time end-index channels &allow-other-keys) &body body) "Execute BODY with VAR bound to a connection that is the result of applying `bag->events' to SOURCE, DEST and ARGS. Ensure that the resulting connection is properly closed." (declare (ignore error-policy backend bag-class replay-strategy start-time start-index end-time end-index channels)) `(with-open-connection (,var (bag->events ,source ,dest ,@args)) ,@body))
2,379
Common Lisp
.lisp
55
26.945455
70
0.50431
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2f5e4a9f186292c5b32512104d5b67b15b90cf4a94e45251bde2b01e936ef79b
37,738
[ -1 ]
37,739
construction.lisp
open-rsx_rsbag-cl/src/rsb/construction.lisp
;;;; construction.lisp --- Construction of channel <-> events connections. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb) ;;; RSB events -> bag (defmethod events->bag ((source string) (dest bag) &rest args &key) (apply #'events->bag (puri:parse-uri source) dest args)) (defun %events->bag/streamish (source dest &rest args &key (if-exists :error if-exists-supplied?) backend transform (flush-strategy nil) (bag-class 'synchronized-bag) &allow-other-keys) (let ((bag (apply #'open-bag dest :bag-class bag-class :direction :output (append (when if-exists-supplied? (list :if-exists if-exists)) (when backend (list :backend backend)) (when transform (list :transform transform)) (when flush-strategy (list :flush-strategy flush-strategy)))))) (apply #'events->bag source bag (remove-from-plist args :backend :flush-strategy :bag-class)))) (macrolet ((define-open-bag-method (type) `(progn (defmethod events->bag ((source string) (dest ,type) &rest args &key) (apply #'events->bag (list source) dest args)) (defmethod events->bag ((source t) (dest ,type) &rest args &key) (apply #'%events->bag/streamish source dest args))))) (define-open-bag-method string) (define-open-bag-method pathname) (define-open-bag-method stream)) ;;; bag -> RSB events (defun %bag->events/streamish (source dest &rest args &key backend transform (bag-class 'synchronized-bag) &allow-other-keys) (let ((bag (apply #'open-bag source :bag-class bag-class :direction :input (append (when backend (list :backend backend)) (when transform (list :transform transform)))))) (apply #'bag->events bag dest (remove-from-plist args :backend :transform :bag-class)))) (macrolet ((define-open-bag-method (type) `(defmethod bag->events ((source ,type) (dest t) &rest args &key) (apply #'%bag->events/streamish source dest args)))) (define-open-bag-method string) (define-open-bag-method pathname) (define-open-bag-method stream)) (defmethod bag->events ((source channel) (dest string) &rest args &key) (apply #'bag->events source (puri:parse-uri dest) args)) (defmethod bag->events ((source channel) (dest function) &key) (make-instance 'endpoint-channel-connection :bag (channel-bag source) :channels (list source) :endpoint dest))
3,764
Common Lisp
.lisp
82
27.219512
74
0.450831
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cb49f1e91348c94ba01f1796a9c1338517fc252199865dfaf42b44b3467dc544
37,739
[ -1 ]
37,740
package.lisp
open-rsx_rsbag-cl/src/rsb/replay/package.lisp
;;;; package.lisp --- Package definition for the rsb.replay module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.rsb.replay (:use #:cl #:alexandria #:split-sequence #:let-plus #:iterate #:more-conditions #:rsbag #:rsbag.transform #:rsbag.view #:rsbag.rsb) ;; Types (:export #:range-boundary/timestamp #:event-id-adjustment) ;; Conditions (:export #:replay-error #:replay-error-strategy #:entry-retrieval-error #:entry-processing-error) ;; Replay protocol (:export #:replay) ;; Sequential processing protocol (:export #:process-event) ;; Timed replay protocol (:export #:schedule-event) ;; Replay bag connection protocol (:export #:connection-strategy #:replay-bag-connection) ;; Service and strategy creation protocol (:export #:strategy ; service #:make-strategy) ;; `error-policy-mixin' mixin class (:export #:error-policy-mixin) ;; index bounds protocol and mixin class (:export #:strategy-start-index #:strategy-end-index #:bounds-mixin) ;; time bounds protocol and mixin class (:export #:strategy-start-time #:strategy-end-time #:time-bounds-mixin) ;; repetitions mixin class (:export #:repetitions-mixin) ;; view creation protocol and mixin class (:export #:make-view #:view-creation-mixin) ;; filtering protocol and mixin class (:export #:strategy-filter #:filtering-mixin) ;; sequential processing protocol and mixin class (:export #:sequential-mixin) ;; speed adjustment protocol and mixin class (:export #:strategy-speed #:speed-adjustment-mixin) ;; delay limiting protocol and mixin class (:export #:strategy-max-delay #:delay-limiting-mixin) ;; external driver protocol and mixin class (:export #:make-commands #:strategy-commands #:find-command #:next-command #:execute-command #:external-driver-mixin) ;; `delay-correcting-mixin' mixin class (:export #:delay-correcting-mixin #:strategy-previous-delay #:strategy-previous-call) ;; `event-id-mixin' mixin class (:export #:event-id-mixin #:strategy-event-id) ;; `timestamp-adjustment-mixin' mixin class (:export #:timestamp-adjustment-mixin #:strategy-adjustments) ;; `recorded-timing' replay strategy class (:export #:recorded-timing) ;; `fixed-rate' replay strategy class (:export #:fixed-rate #:strategy-rate #:strategy-delay) ;; `as-fast-as-possible' replay strategy class (:export #:as-fast-as-possible) ;; `remote-controlled' replay strategy class (:export #:remote-controlled) ;; `interactive' replay strategy class (:export #:interactive #:strategy-stream #:strategy-previous-command) (:documentation "This package contains supporting infrastructure and replay strategy classes."))
3,008
Common Lisp
.lisp
122
20.852459
67
0.696586
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
86a27e41da957d5d59e2ce79e05463a69d627b3ddbb1506e480d0c65b743fead
37,740
[ -1 ]
37,741
fixed-rate.lisp
open-rsx_rsbag-cl/src/rsb/replay/fixed-rate.lisp
;;;; fixed-rate.lisp --- A strategy for replaying events at a fixed rate. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay) ;;; `fixed-rate' replay strategy class (defclass fixed-rate (error-policy-mixin filtering-mixin timed-replay-mixin delay-correcting-mixin speed-adjustment-mixin timestamp-adjustment-mixin print-items:print-items-mixin) ((delay :type positive-real :accessor strategy-delay :documentation "Stores the fixed delay in seconds between publishing subsequent events.")) (:documentation "This strategy replays events in the order they were recorded and, as precisely as possible, with a specified fixed rate.")) (service-provider:register-provider/class 'strategy :fixed-rate :class 'fixed-rate) (defmethod initialize-instance :before ((instance fixed-rate) &key (delay nil delay-supplied?) (rate nil rate-supplied?)) (cond ((and (not delay-supplied?) (not rate-supplied?)) (missing-required-initarg 'fixed-rate :delay-xor-rate)) ((and delay-supplied? rate-supplied?) (incompatible-initargs 'fixed-rate :delay delay :rate rate)))) (defmethod shared-initialize :after ((instance fixed-rate) (slot-names t) &key (delay nil delay-supplied?) (rate nil rate-supplied?)) (cond (delay-supplied? (setf (strategy-delay instance) delay)) (rate-supplied? (setf (strategy-rate instance) rate)))) (defmethod (setf strategy-delay) :before ((new-value real) (strategy fixed-rate)) (check-type new-value positive-real "a positive real number")) (defmethod strategy-rate ((strategy fixed-rate)) (/ (strategy-delay strategy))) (defmethod (setf strategy-rate) ((new-value real) (strategy fixed-rate)) (check-type new-value positive-real "a positive real number") (setf (strategy-delay strategy) (/ new-value))) (defmethod schedule-event ((strategy fixed-rate) (event t) (previous local-time:timestamp) (next local-time:timestamp)) (strategy-delay strategy)) (defmethod print-items:print-items append ((object fixed-rate)) `((:rate ,(strategy-rate object) " ~A Hz" ((:after :bounding-indices)))))
2,783
Common Lisp
.lisp
58
35.37931
73
0.579956
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8ea71fded000bb20525034f17120c4950d49eb2b49c531150bbed24d8b2bb254
37,741
[ -1 ]
37,742
util.lisp
open-rsx_rsbag-cl/src/rsb/replay/util.lisp
;;;; util.lisp --- Utilities used in the rsb.replay module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay) ;;; Class `informer-inject' (defclass informer-injector (channel-items) ((informer :initarg :informer :reader informer-injector-%informer :documentation "Stores the informer that should be associated with the channel.")) (:default-initargs :informer (missing-required-initarg 'informer-injector :informer)) (:documentation "Instance of this helper class inject a given object (usually an `rsb:informer' instance) into each element of the underlying sequence.")) (defmethod sequence:elt ((sequence informer-injector) (index integer)) (append (call-next-method) (list (informer-injector-%informer sequence)))) (defun inject-informer (channel connection) ;; Find the channel-connection for CHANNEL in CONNECTION, extract ;; the informer and pass it to a new `informer-injector' instance. (make-instance 'informer-injector :channel channel :informer (connection-endpoint (find channel (connection-connections connection :include-inner? nil) :test #'member :key #'connection-channels)))) ;;; Utility functions ;;; Return a function of two parameters that calls CALLBACK in the ;;; appropriate way if CALLBACK is non-nil. (defun %make-progress-reporter (sequence callback) (when callback (let ((start 0) (end (max 0 (1- (length sequence))))) (lambda (index timestamp) (if index (funcall callback (/ (1+ (- index start)) (- (1+ end) start)) index start end timestamp) (funcall callback nil nil nil nil nil)))))) ;;; Printing (defun format-source (stream source &optional colon at) (declare (ignore colon at)) (etypecase source (bag-connection (format stream "bag ~A" (connection-bag source)))))
2,214
Common Lisp
.lisp
52
33.75
74
0.625174
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e36ce223b36b296877fd8240f70ce67e5c179de56422222caa3b25df2e61ef3e
37,742
[ -1 ]
37,743
protocol.lisp
open-rsx_rsbag-cl/src/rsb/replay/protocol.lisp
;;;; protocol.lisp --- Protocol functions of the rsb.replay module. ;;;; ;;;; Copyright (C) 2013, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay) ;;; Replay protocol (defgeneric replay (connection strategy &key progress) (:documentation "Replay the events contained in the associated bag of CONNECTION according to STRATEGY. Usually, STRATEGY will mostly influence the timing of the replay. However, things like simulated loss of events or transformations are also possible. If PROGRESS is non-nil it has to be a function accepting five arguments: progress ratio, current index, start index, end index and current timestamp. May signal a `replay-error'. In particular, `entry-retrieval-error' and `entry-processing-error' may be signaled.")) (define-condition-translating-method replay ((connection t) (strategy t) &key &allow-other-keys) (((and error (not replay-error)) entry-retrieval-error) :connection connection :strategy strategy)) ;;; Sequential processing protocol (defgeneric process-event (connection strategy timestamp previous-timestamp event sink) (:documentation "Process the tuple (TIMESTAMP PREVIOUS-TIMESTAMP EVENT SINK), originating from CONNECTION, according to STRATEGY.")) (define-condition-translating-method process-event ((connection t) (strategy t) (timestamp t) (previous-timestamp t) (event t) (sink t)) ((error entry-processing-error) :connection connection :strategy strategy :entry event)) ;;; Timed replay protocol (defgeneric schedule-event (strategy event previous next) (:documentation "Return a relative time in seconds at which EVENT should be replayed according to STRATEGY given timestamps PREVIOUS and NEXT of the previous and current event when recorded. PREVIOUS can be nil at the start of a replay.")) (defmethod schedule-event ((strategy t) (event t) (previous (eql nil)) (next local-time:timestamp)) 0) ;;; Replay strategy service (service-provider:define-service strategy (:documentation "Providers implement event replay strategies. The main difference between strategies is the handling of timing.")) (defgeneric make-strategy (spec &rest args) (:documentation "Return (potentially creating it first) an instance of the replay strategy designated by SPEC.")) (defmethod make-strategy ((spec standard-object) &rest args) (if args (apply #'reinitialize-instance spec args) spec)) (defmethod make-strategy ((spec symbol) &rest args) (if (keywordp spec) (apply #'service-provider:make-provider 'strategy spec args) (let ((provider (find spec (service-provider:service-providers 'strategy) :key (compose #'class-name #'service-provider:provider-class) :test #'eq))) (apply #'service-provider:make-provider 'strategy provider args)))) (defmethod make-strategy ((spec class) &rest args) (let ((provider (find spec (service-provider:service-providers 'strategy) :key #'service-provider:provider-class :test #'eq))) (apply #'service-provider:make-provider 'strategy provider args))) (defmethod make-strategy ((spec cons) &rest args) (apply #'make-strategy (first spec) (append (rest spec) args))) ;;; Bounds protocol (defgeneric strategy-start-index (strategy) (:documentation "Return the start index of the region processed by STRATEGY.")) (defgeneric strategy-end-index (strategy) (:documentation "Return the end index of the region processed by STRATEGY.")) ;;; View creation protocol (defgeneric make-view (connection strategy &key selector) (:documentation "Make and return a sequence view of the events associated to CONNECTION for replay according to STRATEGY. See `rsbag.view:make-serialized-view' for a description of SELECTOR.")) ;;; Fixed-rate strategy protocol (defgeneric strategy-delay (strategy) (:documentation "Return the delay in seconds between events replayed with STRATEGY.")) (defgeneric (setf strategy-delay) (new-value strategy) (:documentation "Set the delay in seconds between events replayed with STRATEGY to NEW-VALUE.")) (defgeneric strategy-rate (strategy) (:documentation "Return the rate in Hertz of events replayed with STRATEGY.")) (defgeneric (setf strategy-rate) (new-value strategy) (:documentation "Set the rate in Hertz of events replayed with STRATEGY to NEW-VALUE.")) ;;; Delay limiting protocol (defgeneric strategy-max-delay (strategy) (:documentation "Return the maximum delay between adjacent events permitted by STRATEGY or nil if STRATEGY does not impose such a constraint.")) (defgeneric (setf strategy-max-delay) (new-value strategy) (:documentation "Set the maximum delay between adjacent events permitted by STRATEGY to NEW-VALUE. When NEW-VALUE is nil STRATEGY does not impose such a constraint.")) ;;; External driver protocol (defgeneric make-commands (strategy sequence &key length step index element emit terminate) (:documentation "Return an alist of items of the form (NAME . FUNCTION) that should be used as the command list of STRATEGY and SEQUENCE. The values of LENGTH, STEP, INDEX, ELEMENT, EMIT and TERMINATE are functions that perform the respective action for SEQUENCE.")) (defgeneric strategy-commands (strategy) (:documentation "Return an alist of items of the form (NAME . FUNCTION) consisting of the available commands for STRATEGY.")) (defgeneric find-command (strategy name &key error?) (:documentation "Find and return the command named NAME within the list of available commands for STRATEGY. If ERROR? is non-nil (the default), signal an error if NAME does not designate a command.")) (defgeneric next-command (strategy) (:documentation "Determine and return the next command that should be executed for STRATEGY. The returned command should be a thunk, usually from the list of available commands of STRATEGY.")) (defgeneric execute-command (strategy command) (:documentation "Execute the thunk COMMAND in a an appropriate way for STRATEGY."))
6,967
Common Lisp
.lisp
153
37.581699
79
0.671981
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e564722e951897cc741cb06eaecd3ee8ae75d89e9cf315691708b467bc2769f8
37,743
[ -1 ]
37,744
types.lisp
open-rsx_rsbag-cl/src/rsb/replay/types.lisp
;;;; types.lisp --- types used in the rsb.replay module. ;;;; ;;;; Copyright (C) 2012-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay) ;;; Bounds specifications (deftype range-boundary/timestamp () "Specification of a boundary of a temporal range. NIL Use actual beginning or end of the sequence to be bounded. a `non-negative-real' Offset in seconds to the start of the sequence. a `negative-real' Negative offset in seconds to the end of the sequence. a `local-time:timestamp' Absolute point in time within the sequence." '(or null non-negative-real negative-real local-time:timestamp)) ;;; Event-id adjustment specification (deftype event-id-adjustment () '(member :keep :replace)) ;;; Timestamp adjustment specifications (deftype timestamp-adjustment-value/now () "Indicates that the current time (i.e. time of replaying the event) should replace the stored timestamp." '(eql :now)) (deftype timestamp-adjustment-value/copy () "A value of the form (:COPY TIMESTAMP-DESIGNATOR) indicates that the timestamp designated by TIMESTAMP-DESIGNATOR should be extracted from the current event and used to replace the stored timestamp." '(cons (eql :copy) (cons rsb:timestamp-designator null))) (deftype timestamp-adjustment-value/delta () `(cons (eql :delta) (cons real null))) (deftype timestamp-adjustment-value () "Specification of a replacement value for a particular timestamp." '(or timestamp-adjustment-value/now timestamp-adjustment-value/copy timestamp-adjustment-value/delta local-time:timestamp)) (deftype timestamp-adjustment-spec () "Replacement rule of the form (TIMESTAMP-DESIGNATOR TIMESTAMP-ADJUSTMENT-VALUE) specifying that the timestamp designated by TIMESTAMP-DESIGNATOR should be replaced with the timestamp value specified by TIMESTAMP-ADJUSTMENT-VALUE" '(cons rsb:timestamp-designator (cons timestamp-adjustment-value null)))
2,067
Common Lisp
.lisp
51
36.54902
74
0.750125
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b1def51900e00127fdaa0084f7ea4c016fa1410697de64f48ed795a6691313f4
37,744
[ -1 ]
37,745
conditions.lisp
open-rsx_rsbag-cl/src/rsb/replay/conditions.lisp
;;;; conditions.lisp --- Conditions used in the rsb.replay module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay) (define-condition replay-error (connection-condition chainable-condition rsbag-error) ((strategy :initarg :strategy :reader replay-error-strategy :documentation "Stores the replay strategy involved in the replay error.")) (:default-initargs :strategy (missing-required-initarg 'replay-error :strategy)) (:report (lambda (condition stream) (format stream "~@<A replay error related to connection ~A and ~ replay strategy ~A ~ occurred.~/more-conditions:maybe-print-cause/~@:>" (connection-condition-connection condition) (replay-error-strategy condition) condition))) (:documentation "Errors of this condition class and subclasses are signaled when errors occur during replay of entries from a bag.")) (define-condition entry-retrieval-error (replay-error) () (:report (lambda (condition stream) (format stream "~@<Error retrieving next entry from ~A for ~ replay according to strategy ~ ~A.~/more-conditions:maybe-print-cause/~@:>" (connection-condition-connection condition) (replay-error-strategy condition) condition))) (:documentation "This error is signaled when the retrieval of an entry from a bag for replay fails.")) (define-condition entry-processing-error (entry-condition replay-error) () (:report (lambda (condition stream) (format stream "~@<Error processing entry ~A from ~A during ~ replay according to strategy ~ ~A.~/more-conditions:maybe-print-cause/~@:>" (entry-condition-entry condition) (connection-condition-connection condition) (replay-error-strategy condition) condition))) (:documentation "This error is signaled when processing of an entry fails during replay."))
2,338
Common Lisp
.lisp
55
32.654545
71
0.6086
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
223e490c70e0bfc53a9c796febbd5bb740046601bc1951a243405e564ca22c81
37,745
[ -1 ]
37,746
remote-controlled.lisp
open-rsx_rsbag-cl/src/rsb/replay/remote-controlled.lisp
;;;; remote-controlled.lisp --- Strategy for RPC-controlled replay. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay) ;;; Command queue protocol (defgeneric enqueue (strategy command) (:documentation "Queue COMMAND for execution by STRATEGY.")) ;;; `remote-controlled' replay strategy class (defclass remote-controlled (error-policy-mixin filtering-mixin external-driver-mixin timestamp-adjustment-mixin rsb:uri-mixin print-items:print-items-mixin) ((rsb::uri :accessor strategy-control-uri) (server :accessor strategy-%server :documentation "Stores the server that exposes the replay control methods to clients.") (queue :type lparallel.queue:queue :reader strategy-%queue :initform (lparallel.queue:make-queue) :documentation "Stores a queue of replay control commands.")) (:default-initargs :uri (missing-required-initarg 'remote-controlled :uri)) (:documentation "Exposes replay control commands via an RPC server. Clients invoke the methods to control the replay. At least the following commands are available: length(): uint64 Return the length of the sequence of all events. relativelength(): uint64 Return the length of the replayed (sub-)sequence of all events. index(): uint64 Return the current position in the replayed sequence. relativeindex(): uint64 Return the current position relative to the start of the replayed (sub-)sequence. next(): uint64 Move the replay cursor to the next entry, return new index. previous(): uint64 Move the replay cursor to the previous entry, return new index. seek(new-position: uint64): void Position the replay cursor at the supplied entry index. emit(): void Publish the entry at which the replay cursor is currently positioned. emitandnext(): uint64 Publish the entry at which the replay cursor is currently positioned, advance to the next entry, return new index. get(): bytes Return the entry at which the replay cursor is currently positioned. Do not emit or change anything. quit(): void Terminate the replay.")) (service-provider:register-provider/class 'strategy :remote-controlled :class 'remote-controlled) (defmethod (setf strategy-%commands) :after ((new-value list) (strategy remote-controlled)) ;; Create methods in the RPC server for the elements of NEW-VALUE. (let+ (((&accessors-r/o (server strategy-%server)) strategy) ((&flet make-command (function request future) (lambda () (handler-case (let ((result (multiple-value-list (apply function request)))) (setf (rsb.patterns.request-reply:future-result future) (if result (first result) rsb.converter:+no-value+))) ; TODO(jmoringe): ugly (error (condition) (setf (rsb.patterns.request-reply:future-error future) condition))))))) ;; Remove registered methods from the server. (iter (for method in (rsb.patterns.request-reply:server-methods server)) (setf (rsb.patterns.request-reply:server-method server (rsb.patterns.request-reply:method-name method)) nil)) ;; Create wrapper functions for commands and register ;; corresponding server methods. (iter (for name-and-lambda in new-value) ;; We cannot use iterate for destructuring since the closed ;; over variables NAME and LAMBDA would change due during ;; iteration. (let+ (((name . lambda) name-and-lambda) (name (string-downcase name))) (setf (rsb.patterns.request-reply:server-method server name) (lambda (&rest request) (let ((future (make-instance 'rsb.patterns.request-reply:future))) (enqueue strategy (make-command lambda request future)) (let ((result (rsb.patterns.request-reply:future-result future))) ; TODO(jmoringe): cumbersome (if (eq result rsb.converter:+no-value+) (values) result))))))))) (defmethod enqueue ((strategy remote-controlled) (command t)) (lparallel.queue:push-queue command (strategy-%queue strategy))) (defmethod next-command ((strategy remote-controlled)) (lparallel.queue:pop-queue (strategy-%queue strategy))) (defmethod replay ((connection replay-bag-connection) (strategy remote-controlled) &key &allow-other-keys) (let+ (((&structure strategy- control-uri (server %server) num-repetitions) strategy)) (rsb:with-participant (server* :local-server control-uri) (setf server server*) (call-repeatedly num-repetitions (lambda () (call-next-method))))))
5,387
Common Lisp
.lisp
111
37.441441
116
0.62438
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8b8489fe001e0520435da14b3e24e9af13201c623229119ffe152e2798b460f1
37,746
[ -1 ]
37,747
recorded-timing.lisp
open-rsx_rsbag-cl/src/rsb/replay/recorded-timing.lisp
;;;; recorded-timing.lisp --- A strategy for replaying events with the recorded timing. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay) ;;; `recorded-timing' replay strategy class (defclass recorded-timing (error-policy-mixin filtering-mixin timed-replay-mixin delay-correcting-mixin delay-limiting-mixin speed-adjustment-mixin timestamp-adjustment-mixin print-items:print-items-mixin) () (:documentation "This strategy replays events in the order they were recorded and, as much as possible, with identical local temporal relations. A faithful replay with respect to global temporal relations (e.g. time between first and last event) is not attempted explicitly. Besides this default \"faithful\" replay timing, variations of the recorded timing can be produced as follows: :speed SPEED Scale all individual delays between events by SPEED. I.e. when SPEED is 0.5, all delays are doubled. :max-delay DELAY Constrain all individual delays between events to be at most DELAY seconds. The intention is replaying events as recorded when they originally occurred in quick succession but squash large \"gaps\" in the sequence of events into short pauses of DELAY seconds. ")) (service-provider:register-provider/class 'strategy :recorded-timing :class 'recorded-timing) (defmethod schedule-event ((strategy recorded-timing) (event t) (previous local-time:timestamp) (next local-time:timestamp)) (local-time:timestamp-difference next previous))
1,928
Common Lisp
.lisp
40
37.65
87
0.646965
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
bacac97cd98653516bad804853a15dc28585e9cdb6034a12be520901081a3a9c
37,747
[ -1 ]
37,748
as-fast-as-possible.lisp
open-rsx_rsbag-cl/src/rsb/replay/as-fast-as-possible.lisp
;;;; as-fast-as-possible.lisp --- A strategy for replaying events as fast as possible. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay) ;;; `as-fast-as-possible' replay strategy class (defclass as-fast-as-possible (error-policy-mixin filtering-mixin sequential-mixin timestamp-adjustment-mixin print-items:print-items-mixin) () (:documentation "Replays events in the recorded order, but as fast as possible. Consequently, recorded timestamps are only used to establish the playback order of events, but not for any kind of replay timing.")) (service-provider:register-provider/class 'strategy :as-fast-as-possible :class 'as-fast-as-possible)
892
Common Lisp
.lisp
20
36.15
86
0.652826
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
44f381dbdd077bd51dec68fc54b52356f86d6b3b8fa35540c59660f78ae71fe7
37,748
[ -1 ]
37,749
construction.lisp
open-rsx_rsbag-cl/src/rsb/replay/construction.lisp
;;;; construction.lisp --- Construction of channel <-> events replay connections. ;;;; ;;;; Copyright (C) 2012-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay) ;;; Multiple bag sources ;;; Relies on string-specialized method. (defmethod bag->events ((source sequence) (dest t) &rest args &key (replay-strategy :recorded-timing)) (when (length= 1 source) (return-from bag->events (apply #'bag->events (first-elt source) dest args))) (let* ((connections (map 'list (apply #'rcurry #'bag->events dest :connection-class 'bag-connection (remove-from-plist args :replay-strategy)) source)) (other-args (remove-from-plist args :backend :transform :bag-class :error-policy :replay-strategy :channels)) (strategy (apply #'make-strategy replay-strategy other-args))) (make-instance 'replay-multi-bag-connection :connections connections :strategy strategy))) ;;; Bag source (defmethod bag->events ((source bag) (dest t) &rest args &key (connection-class 'replay-bag-connection) (error-policy nil error-policy-supplied?) (replay-strategy :recorded-timing replay-strategy-supplied?) (channels t) (backend nil backend-supplied?) (transform nil transform-supplied?) (bag-class nil bag-class-supplied?)) (let+ (((&flet check-arg (name value supplied?) (when supplied? (incompatible-arguments 'source source name value))))) (check-arg :backend backend backend-supplied?) (check-arg :transform transform transform-supplied?) (check-arg :bag-class bag-class bag-class-supplied?)) (let+ ((predicate (if (eq channels t) (constantly t) channels)) (channels (remove-if-not predicate (bag-channels source))) (other-args (remove-from-plist args :connection-class :error-policy :replay-strategy :channels)) ((&flet do-channel (channel) (apply #'bag->events channel dest other-args))) (connections (map 'list #'do-channel channels)) (strategy (when (or replay-strategy-supplied? (eq connection-class 'replay-bag-connection)) (apply #'make-strategy replay-strategy other-args)))) (apply #'make-instance connection-class :bag source :connections connections (append (when strategy (list :strategy strategy)) (when error-policy-supplied? (list :error-policy error-policy)))))) (defmethod bag->events ((source channel) (dest puri:uri) &key) (let+ ((name (%legalize-name (if (starts-with #\/ (channel-name source)) (subseq (channel-name source) 1) (channel-name source)))) ((&values uri prefix-scope) (%make-playback-uri name dest)) ((&plist-r/o (type :type)) (channel-meta-data source)) (converter (make-instance 'rsb.converter:force-wire-schema :wire-schema (if (consp type) (second type) :bytes))) (participant (apply #'rsb:make-participant :informer uri :converters `((t . ,converter)) (when-let ((transform (%make-scope-transform prefix-scope type))) (list :transform (list transform)))))) (make-instance 'participant-channel-connection :bag (channel-bag source) :channels (list source) :endpoint participant))) ;;; Utility functions ;;; Remove characters from NAME which would be illegal in scope names. (defun %legalize-name (name) (if-let ((colon-index (position #\: name))) (%legalize-name (subseq name 0 colon-index)) (remove-if (complement (disjoin #'alphanumericp (curry #'char-equal #\/))) name))) ;;; Return two values: ;;; ;;; 1. An URI that is the result of merging CHANNEL-NAME and ;;; BASE-URI. In the returned URI, normalize the path component of ;;; BASE-URI and preserve query component of BASE-URI, if present. ;;; ;;; 2. A `scope' or `nil' that is the prefix-`scope' implied by ;;; BASE-URI. `nil' is returned when BASE-URI does not imply prefix ;;; scope. (defun %make-playback-uri (channel-name base-uri) (let ((base-uri (puri:copy-uri base-uri))) ;; If BASE-URI has a path, ensure it ends with "/" to prevent ;; `puri:merge-uri' from acting differently depending on whether ;; there is a "/" or not. (unless (ends-with #\/ (puri:uri-path base-uri)) (setf (puri:uri-path base-uri) (concatenate 'string (puri:uri-path base-uri) "/"))) (let ((result (puri:merge-uris channel-name base-uri)) (prefix (unless (string= (puri:uri-path base-uri) "/") (rsb:make-scope (puri:uri-path base-uri) :intern? t)))) ;; Merging stomps on the query part, if any, of ;; BASE-URI. Restore it afterward. (when (puri:uri-query base-uri) (setf (puri:uri-query result) (puri:uri-query base-uri))) (values result prefix)))) ;;; Return a transform object which adds SCOPE as a prefix scope to ;;; the scopes of transformed events if TYPE is of the form ;;; ;;; (RSB-EVENT* WIRE-SCHEMA) ;;; ;;; . (defun %make-scope-transform (scope type) (when (and scope (typep type '(cons keyword)) (starts-with-subseq "RSB-EVENT" (symbol-name (first type)))) (lambda (event) (setf (rsb:event-scope event) (rsb:merge-scopes (rsb:event-scope event) scope)) event)))
6,224
Common Lisp
.lisp
132
36.522727
82
0.569737
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b3d3cfab51fc27e183e32030b987fb2c379aa521990ca3bd8c06a458aebb6910
37,749
[ -1 ]
37,750
bag-connections.lisp
open-rsx_rsbag-cl/src/rsb/replay/bag-connections.lisp
;;;; bag-connections.lisp --- Classes for replay bag connections. ;;;; ;;;; Copyright (C) 2012-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay) ;;; `replay-connection-mixin' class (defclass replay-connection-mixin () ((strategy :initarg :strategy :reader connection-strategy :documentation "Stores the strategy that is used for replaying events from the associated bag.")) (:default-initargs :strategy (missing-required-initarg 'replay-connection-mixin :strategy)) (:documentation "Stores a strategy for replaying events from a source.")) (defmethod (setf rsb.ep:processor-error-policy) :before ((new-value t) (object replay-connection-mixin)) (let+ (((&structure-r/o connection- strategy) object)) (setf (rsb.ep:processor-error-policy strategy) new-value))) ;;; `replay-bag-connection' class (defclass replay-bag-connection (bag-connection replay-connection-mixin) () (:documentation "Associates a replay strategy, a source bag and sinks to collaboratively replay events.")) ;;; `replay-multi-bag-connection' class (defclass replay-multi-bag-connection (composite-connection-mixin rsb.ep:error-policy-mixin replay-connection-mixin) () (:documentation "Associates a replay strategy, multiple source bags and sinks to collaboratively replay events."))
1,550
Common Lisp
.lisp
37
34.918919
75
0.672425
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
236475bd0d576762ea4682a80d2d919b1687ab356b15211262b2fb64d069dd0d
37,750
[ -1 ]
37,751
package.lisp
open-rsx_rsbag-cl/src/rsb/recording/package.lisp
;;;; package.lisp --- Package definition for the rsb.recording module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.rsb.recording (:use #:cl #:alexandria #:let-plus #:more-conditions #:rsbag #:rsbag.rsb) ;; Conditions (:export #:recording-error #:entry-storage-error) ;; Processing protocol (:export #:process-event) ;; Channel allocation strategy protocol (:export #:channel-name-for #:channel-transform-for #:channel-format-for #:channel-meta-data-for #:make-channel-for #:ensure-channel-for #:strategy ; service #:make-strategy) (:documentation "This package contains supporting infrastructure and channel allocation strategy classes."))
817
Common Lisp
.lisp
33
21.212121
70
0.700258
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f6e00f006fbcb964e70e5beec505f926d128a41f9812107ad3552cfa28191229
37,751
[ -1 ]
37,752
protocol.lisp
open-rsx_rsbag-cl/src/rsb/recording/protocol.lisp
;;;; protocol.lisp --- Protocol functions used in the rsb.recording module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.recording) ;;; Processing protocol (defgeneric process-event (connection timestamp event) (:documentation "Record EVENT at TIMESTAMP in the destination of CONNECTION.")) ;;; Channel allocation protocol (defgeneric channel-name-for (connection event strategy) (:documentation "Return a channel name string designating the channel within CONNECTION in which EVENT should be stored according to STRATEGY.")) (defgeneric channel-transform-for (connection event strategy) (:documentation "Derive, construct and return a transform for the channel within CONNECTION in which EVENT should be stored according to STRATEGY.")) (defgeneric channel-format-for (connection transform event strategy) (:documentation "Return a representation of the type of data/serialization mechanism according to which the data of EVENT, after being encoded by TRANSFORM, will be stored in the channel within CONNECTION allocated by STRATEGY.")) (defgeneric channel-meta-data-for (connection transform event strategy) (:documentation "Construct and return a meta-data plist for the channel within CONNECTION in which EVENT should be stored according to STRATEGY taking into account TRANSFORM, the associated transform for the channel.")) (defgeneric make-channel-for (connection event strategy) (:documentation "Return two values describing a channel in CONNECTION in which EVENT can be stored according to STRATEGY: 1) The meta-data plist for the channel 2) the transform for the channel.")) (defgeneric ensure-channel-for (connection event strategy) (:documentation "Find or make and return a channel in CONNECTION in which EVENT can be stored according to STRATEGY.")) ;;; Default behavior (defmethod channel-format-for ((connection t) (transform (eql nil)) (event t) (strategy t)) ;; Default behavior is to not associate a channel format. nil) (defmethod channel-format-for ((connection t) (transform t) (event t) (strategy t)) ;; Default behavior for non-nil TRANSFORM is to retrieve the channel ;; format from TRANSFORM. (rsbag.transform:transform-format transform)) ;;; Channel allocation strategy class family (service-provider:define-service strategy (:documentation "Providers implement channel selection and allocation strategies.")) (defgeneric make-strategy (spec &rest args) (:documentation "Return (potentially creating it first) an instance of the channel strategy designated by SPEC.")) (defmethod make-strategy ((spec standard-object) &rest args) (if args (apply #'reinitialize-instance spec args) spec)) (defmethod make-strategy ((spec symbol) &rest args) (if (keywordp spec) (apply #'service-provider:make-provider 'strategy spec args) (let ((provider (find spec (service-provider:service-providers 'strategy) :key (compose #'class-name #'service-provider:provider-class) :test #'eq))) (apply #'service-provider:make-provider 'strategy provider args)))) (defmethod make-strategy ((spec class) &rest args) (let ((provider (find spec (service-provider:service-providers 'strategy) :key #'service-provider:provider-class :test #'eq))) (apply #'service-provider:make-provider 'strategy provider args))) (defmethod make-strategy ((spec cons) &rest args) (apply #'make-strategy (first spec) (append (rest spec) args)))
3,990
Common Lisp
.lisp
87
38.528736
79
0.68787
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
41138f96ea8ced488615917a7684b508732db924e19876267546107e5483dc0d
37,752
[ -1 ]
37,753
channel-connections.lisp
open-rsx_rsbag-cl/src/rsb/recording/channel-connections.lisp
;;;; channel-connections.lisp --- A class for recording channel connections. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.recording) (defmethod process-event ((connection recording-bag-connection) (timestamp t) (event t)) (let ((connections (connection-connections connection :include-inner? nil))) (assert (length= 1 connections)) (process-event (first connections) timestamp event))) ;;; `recording-channel-connection' class (defclass recording-channel-connection (channel-connection) ((timestamp :initarg :timestamp :type keyword :reader connection-timestamp :initform :create :documentation "Stores the key of the event timestamp that should be used to index events in the associated channel. Defaults to the create timestamp.") (strategy :initarg :strategy :reader connection-strategy :documentation "Stores a channel allocation/selection strategy.")) (:default-initargs :strategy (missing-required-initarg 'recording-channel-connection :strategy)) (:documentation "Instances of this represent class represent connections being established between RSB listeners and bag channels when RSB events are recorded into bag channels.")) (defmethod process-event ((connection recording-channel-connection) (timestamp local-time:timestamp) (event t)) (let+ (((&structure-r/o connection- strategy) connection) ((&values channel found?) (ensure-channel-for connection event strategy))) (unless found? (push channel (connection-channels connection))) (setf (entry channel timestamp) event))) (defmethod process-event ((connection recording-channel-connection) (timestamp null) (event rsb:event)) (let+ (((&structure-r/o connection- timestamp) connection)) (process-event connection (rsb:timestamp event timestamp) event))) (defmethod rsb.ep:handle ((sink recording-channel-connection) (event rsb:event)) ;; HACK: If necessary, hack our own survey event into compliance. (unless (rsb:meta-data event :rsb.transport.wire-schema) (setf (rsb:meta-data event :rsb.transport.wire-schema) "void" (rsb:event-data event) (nibbles:octet-vector))) (let+ (((&structure-r/o connection- timestamp) sink)) (process-event sink (rsb:timestamp event timestamp) event))) (defmethod print-items:print-items append ((object recording-channel-connection)) `((:timestamp ,(connection-timestamp object) "~A" ((:before :direct-connection-count))))) ;;; `recording-participant-channel-connection' class (defclass recording-participant-channel-connection (participant-channel-connection recording-channel-connection) () (:documentation "Recording channel connection whose endpoint is a participant.")) (defmethod start ((connection recording-participant-channel-connection)) (let+ (((&accessors-r/o (participant connection-endpoint)) connection)) (push connection (rsb.ep:handlers participant)))) (defmethod stop ((connection recording-participant-channel-connection)) (let+ (((&accessors-r/o (participant connection-endpoint)) connection)) (removef (rsb.ep:handlers participant) connection)))
3,641
Common Lisp
.lisp
70
43.457143
83
0.668541
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3e5d6cbda34ed01d9366ccec1878affd89423ecb76f3b5a4ebc7c8d5bdb6352e
37,753
[ -1 ]
37,754
conditions.lisp
open-rsx_rsbag-cl/src/rsb/recording/conditions.lisp
;;;; conditions.lisp --- Conditions used in the rsb.recording module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.recording) (define-condition recording-error (connection-condition chainable-condition rsbag-error) () (:report (lambda (condition stream) (format stream "~@<A recording error related to ~A ~ occurred.~/more-conditions:maybe-print-cause/~@:>" (connection-condition-connection condition) condition))) (:documentation "Errors of this condition class and subclasses are signaled when errors occur during event recording into a bag.")) (define-condition entry-storage-error (entry-condition recording-error) () (:report (lambda (condition stream) (format stream "~@<Error storing entry ~A in ~ ~A.~/more-conditions:maybe-print-cause/~@:>" (entry-condition-entry condition) (connection-condition-connection condition) condition))) (:documentation "This error is signaled when an entry cannot be stored during a recording process."))
1,310
Common Lisp
.lisp
32
31.78125
71
0.618039
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
9dbe4fd20a55831765b29e81a849e89c29fc083cc467864a5c1f79c1b62d39c1
37,754
[ -1 ]
37,755
channel-strategies.lisp
open-rsx_rsbag-cl/src/rsb/recording/channel-strategies.lisp
;;;; channel-strategies.lisp --- Strategy classes for allocating channels. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.recording) ;;; `ensure-channel-mixin' (defclass ensure-channel-mixin () () (:documentation "Adds basic {ensure,make}-channel-for behavior to strategy classes.")) (defmethod ensure-channel-for ((connection channel-connection) (event t) (strategy ensure-channel-mixin)) (let+ ((name (channel-name-for connection event strategy)) (bag (connection-bag connection)) (found? t) ((&flet make-channel (condition) (declare (ignore condition)) (setf found? nil) (let+ (((&values meta-data transform) (make-channel-for connection event strategy))) (invoke-restart 'create meta-data :transform transform))))) (values (bag-channel bag name :if-does-not-exist #'make-channel) found?))) (defmethod make-channel-for ((connection t) (event t) (strategy ensure-channel-mixin)) (let* ((transform (channel-transform-for connection event strategy)) (meta-data (channel-meta-data-for connection transform event strategy))) (values meta-data transform))) ;;; `delegating-mixin' (defclass delegating-mixin () ((next :reader strategy-next :accessor strategy-%next :documentation "Stores a strategy that should be used to perform operations not or partially implemented by this strategy.")) (:default-initargs :next (missing-required-initarg 'delegating-mixin :next)) (:documentation "Adds delegation of operations to another strategy instance. Intended to be mixed into strategy classes that implement only some aspects of the protocol and delegate other aspect to a different strategy.")) (defmethod shared-initialize :after ((instance delegating-mixin) (slots-names t) &key (next nil next-supplied?)) (when next-supplied? (setf (strategy-%next instance) (make-strategy next)))) (defmethod rsb.ep:access? ((processor delegating-mixin) (part t) (access t)) (rsb.ep:access? (strategy-next processor) part access)) (defmethod channel-name-for ((connection t) (event t) (strategy delegating-mixin)) (channel-name-for connection event (strategy-next strategy))) (defmethod channel-transform-for ((connection t) (event t) (strategy delegating-mixin)) (channel-transform-for connection event (strategy-next strategy))) (defmethod channel-format-for ((connection t) (transform t) (event t) (strategy delegating-mixin)) (channel-format-for connection transform event (strategy-next strategy))) (defmethod channel-meta-data-for ((connection t) (transform t) (event t) (strategy delegating-mixin)) (channel-meta-data-for connection transform event (strategy-next strategy))) ;;; `scope-and-type' channel allocation strategy class (defclass scope-and-type (ensure-channel-mixin) () (:documentation "Allocates a channel for each combination of scope and wire-schema. The channel allocation for a given combination is performed when the first event exhibiting that combination is processed. Channel names are of the form SCOPE:TYPE where SCOPE is the scope string of the received event (including the final \"/\") and TYPE is the wire-schema string of the payload of the event. As an example, an event on scope /foo/bar/ with wire-schema \".rst.vision.Image\" would be stored in a channel called \"/foo/bar/:.rst.vision.Image\".")) (service-provider:register-provider/class 'strategy :scope-and-type :class 'scope-and-type) (macrolet ((needs (part) `(defmethod rsb.ep:access? ((processor scope-and-type) (part (eql ,part)) (access (eql :read))) t))) (needs :scope) (needs :meta-data)) (defmethod channel-name-for ((connection t) (event rsb:event) (strategy scope-and-type)) (scope+wire-schema->channel-name event)) (defmethod channel-transform-for ((connection t) (event rsb:event) (strategy scope-and-type)) (let ((wire-schema (make-keyword (rsb:meta-data event :rsb.transport.wire-schema)))) (rsbag.transform:make-transform rsbag.transform:+rsb-schema-name+ wire-schema))) (defmethod channel-meta-data-for ((connection t) (transform t) (event rsb:event) (strategy scope-and-type)) '()) (defmethod channel-meta-data-for ((connection participant-channel-connection) (transform t) (event rsb:event) (strategy scope-and-type)) (let+ (((&structure-r/o connection- bag (participant endpoint)) connection) ((&accessors-r/o (id rsb:participant-id)) participant) (format (channel-format-for bag transform event strategy))) (list* :source-name (princ-to-string id) :source-config (princ-to-string (rsb:abstract-uri participant)) (when format (list :format format))))) ;;; `collapse-reserved' (defclass collapse-reserved (ensure-channel-mixin delegating-mixin) () (:documentation "Collapses scopes reserved by RSB into their first three components. This, for example, prevents introspection scopes like /__rsb/introspection/participants/ID/… from creating two channels (Hello and Bye) for each participant.")) (service-provider:register-provider/class 'strategy :collapse-reserved :class 'collapse-reserved) (defmethod rsb.ep:access? ((processor collapse-reserved) (part (eql :scope)) (access (eql :read))) t) (defmethod channel-name-for ((connection t) (event rsb:event) (strategy collapse-reserved)) (let ((scope (rsb:event-scope event))) (if (rsb:sub-scope?/no-coerce scope rsb:*reserved-scope*) ;; Collapse reserved scopes to three components. (scope+wire-schema->channel-name event (rsb:make-scope (subseq (rsb:scope-components scope) 0 3))) ;; All other events go into the usual channels. (channel-name-for connection event (strategy-next strategy))))) ;;; Utility functions (defun scope+wire-schema->channel-name (event &optional (scope (rsb:event-scope event))) (if-let ((wire-schema (rsb:meta-data event :rsb.transport.wire-schema))) (format nil "~A:~A" (rsb:scope-string scope) wire-schema) (error "~@<Event ~A does not have a ~A meta-data item.~@:>" event :rsb.transport.wire-schema)))
7,745
Common Lisp
.lisp
154
37.863636
81
0.587247
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6bf994e32b394cb5c112eb6f126c659c9c732d5bfa46c19e4a12f81b850a0b27
37,755
[ -1 ]
37,756
construction.lisp
open-rsx_rsbag-cl/src/rsb/recording/construction.lisp
;;;; construction.lisp --- Construction of channel <-> events recording connections. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.recording) ;;; Recording with RSB listener source (defmethod events->bag ((source rsb:listener) (dest bag) &key (timestamp :send) (channel-strategy :scope-and-type) &allow-other-keys) (make-instance 'recording-participant-channel-connection :bag dest :endpoint source :timestamp timestamp :strategy (make-strategy channel-strategy))) (defmethod events->bag ((source puri:uri) (dest bag) &rest args &key (transports '((t :expose (:rsb.transport.wire-schema) rsb:&inherit))) (filters nil filters-supplied?)) (let ((listener (apply #'rsb:make-participant :listener source :transports transports :converters '((t . :fundamental-null)) (when filters-supplied? (list :filters filters))))) (apply #'events->bag listener dest (remove-from-plist args :transports :filters)))) (defmethod events->bag ((source sequence) (dest bag) &rest args &key (error-policy nil error-policy-supplied?) (introspection-survey? t introspection-survey?-supplied?) (start? t)) (let* ((args/channel (remove-from-plist args :error-policy :introspection-survey? :start?)) (connection (apply #'make-instance 'recording-bag-connection :bag dest :connections (map 'list (lambda (source) (apply #'events->bag source dest args/channel)) source) (append (when introspection-survey?-supplied? (list :introspection-survey? introspection-survey?)) (when error-policy-supplied? (list :error-policy error-policy)))))) (when start? (start connection)) connection)) ;;; Recording without source (defmethod events->bag ((source null) (dest bag) &key (error-policy nil error-policy-supplied?) (timestamp :send) (channel-strategy :scope-and-type) &allow-other-keys) (apply #'make-instance 'recording-bag-connection :bag dest :connections (list (make-instance 'recording-channel-connection :bag dest :timestamp timestamp :strategy (make-strategy channel-strategy))) (when error-policy-supplied? (list :error-policy error-policy))))
3,523
Common Lisp
.lisp
73
29.09589
88
0.459483
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
aa5f0031bfe1e7e1dcbdd2afc0c826c416060994d4605c37e681338d5284659f
37,756
[ -1 ]
37,757
package.lisp
open-rsx_rsbag-cl/compat/0.5/src/transform/package.lisp
;;; package.lisp --- Package definition for the transform module. ;; ;; Copyright (C) 2011-2018 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:defpackage :rsbag.transform (:use :cl :alexandria :let-plus :iterate :more-conditions) ;; Conditions (:export :transform-error :transform-error-transform :encoding-error :transform-error-domain-object :decoding-error :transform-error-encoded) ;; Transform protocol (:export :transform-name :decode :encode) (:documentation "This package contains the transformation protocol and infrastructure used in rsbag."))
1,423
Common Lisp
.lisp
46
28.543478
70
0.740146
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
26271985857ec9c6a3eb7dbbe2912e4028ed32fe72a3cb89f19dd61a5930411d
37,757
[ -1 ]
37,758
protocol.lisp
open-rsx_rsbag-cl/compat/0.5/src/transform/protocol.lisp
;;; protocol.lisp --- Protocol functions of the transform module. ;; ;; Copyright (C) 2011-2016 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:in-package :rsbag.transform) ;;; Transform protocol ;; (defgeneric transform-name (transform) (:documentation "Return a keyword identifying TRANSFORM.")) (defgeneric encode (transform domain-object) (:documentation "Encode DOMAIN-OBJECT using TRANSFORM and return the result.")) (defgeneric decode (transform data) (:documentation "Decode DATA using TRANSFORM and return the decoded domain-object.")) ;;; Default behavior ;; (defmethod transform-name ((transform standard-object)) "Default behavior is to use the class name of TRANSFORM to identify TRANSFORM." (nth-value 0 (make-keyword (class-name (class-of transform))))) (defmethod encode :around ((transform t) (domain-object t)) "Establish a use-value restart and wrap arbitrary conditions in an `encoding-error' instance." (handler-bind (((and error (not encoding-error)) #'(lambda (condition) (error 'encoding-error :transform transform :domain-object domain-object :cause condition)))) (restart-case (call-next-method) (use-value (value) :report (lambda (stream) (format stream "~@<Specify a value to use ~ instead of the result of the failed encoding.~@:>")) :interactive (lambda () (format *query-io* "~@<Enter replacement ~ value (unevaluated): ~@:>") (force-output *query-io*) (list (read *query-io*))) value)))) (defmethod decode :around ((transform t) (data t)) "Establish a use-value restart and wrap arbitrary conditions in a `decoding-error' instance." (handler-bind (((and error (not decoding-error)) #'(lambda (condition) (error 'decoding-error :transform transform :encoded data :cause condition)))) (restart-case (call-next-method) (use-value (value) :report (lambda (stream) (format stream "~@<Specify a value to use ~ instead of the result of the failed decoding.~@:>")) :interactive (lambda () (format *query-io* "~@<Enter replacement ~ value (unevaluated): ~@:>") (force-output *query-io*) (list (read *query-io*))) value))))
3,093
Common Lisp
.lisp
88
31.806818
70
0.696858
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5791792e1f960946c8fe3b9e13a56a464872820cc8a92480dd74ae4e04fd65ab
37,758
[ -1 ]
37,759
conditions.lisp
open-rsx_rsbag-cl/compat/0.5/src/transform/conditions.lisp
;;; conditions.lisp --- Conditions used in the transform module. ;; ;; Copyright (C) 2011, 2012 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:in-package :rsbag.transform) (define-condition transform-error (error) ((transform :initarg :transform :reader transform-error-transform :documentation "Stores the transform instance that was used in the failed transform operation.")) (:report (lambda (condition stream) (format stream "~@<A transformation involving the transform ~A ~ failed.~@:>" (transform-error-transform condition)))) (:documentation "Errors of this condition class and its subclasses are signaled when a transform fails.")) (define-condition encoding-error (transform-error chainable-condition) ((domain-object :initarg :domain-object :reader transform-error-domain-object :documentation "Stores the domain object the encoding of which failed.")) (:report (lambda (condition stream) (format stream "~@<The domain object ~S could not be encoded by ~ the transform ~A.~/more-conditions::maybe-print-cause/~@:>" (transform-error-domain-object condition) (transform-error-transform condition) condition))) (:documentation "This error is signaled when the encoding of a domain object for storage in bag fails.")) (define-condition decoding-error (transform-error chainable-condition) ((encoded :initarg :encoded :reader transform-error-encoded :documentation "Stores the encoded data, the decoding of which failed.")) (:report (lambda (condition stream) (format stream "~@<The encoded value ~S could not be decoded by ~ the transform ~A.~/more-conditions::maybe-print-cause/~@:>" (transform-error-encoded condition) (transform-error-transform condition) condition))) (:documentation "This error is signaled when the decoding of data, usually retrieved from a bag, fails."))
2,762
Common Lisp
.lisp
71
35.690141
70
0.731299
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
113f23cd0c6380e104a4c35a0616971c3eb6df1df401c378f6c05e2bfa87b5b1
37,759
[ -1 ]
37,760
rsb-event.lisp
open-rsx_rsbag-cl/compat/0.5/src/transform/rsb-event.lisp
;;; rsb-event.lisp --- (De)serialization of RSB events. ;; ;; Copyright (C) 2011, 2012, 2015, 2016 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:in-package :rsbag.transform) (defclass rsb-event () ((wire-schema :initarg :wire-schema :type keyword :reader transform-wire-schema :documentation "Stores the associated wire-schema of (de)serialized events.") (holder :reader %transform-holder :initform (make-instance 'rsb.serialization:event) :documentation "Stores a data-holder instance that is reused during (de)serialization for efficiency reasons.")) (:default-initargs :wire-schema (required-argument :wire-schema)) (:documentation "Instances of this transform class (de)serialize RSB events from/to octet vectors.")) (defmethod transform-name ((transform rsb-event)) (list (call-next-method) (transform-wire-schema transform))) (defmethod encode ((transform rsb-event) (domain-object rsb:event)) (let+ (((&accessors-r/o (holder %transform-holder)) transform) ((&accessors-r/o (causes rsb.serialization:event-causes) (meta-data rsb.serialization:event-meta-data)) holder) ((&flet+ process-timestamp (name) (let ((value (rsb:timestamp domain-object name))) (if value (timestamp->unix-microseconds value) 0))))) ;; Prepare meta-data container. (reinitialize-instance meta-data :create-time (process-timestamp :create) :send-time (process-timestamp :send) :receive-time (process-timestamp :receive) :deliver-time (process-timestamp :deliver)) (setf (fill-pointer (rsb.protocol:meta-data-user-infos meta-data)) 0 (fill-pointer (rsb.protocol:meta-data-user-times meta-data)) 0) ;; Add user meta-data. (iter (for (key value) on (rsb:event-meta-data domain-object) :by #'cddr) (vector-push-extend (make-instance 'rsb.protocol:user-info :key (keyword->bytes key) :value (string->bytes value)) (rsb.protocol:meta-data-user-infos meta-data))) ;; Add user timestamps. (iter (for (key value) on (rsb:event-timestamps domain-object) :by #'cddr) (unless (member key '(:create :send :receive :deliver)) (vector-push-extend (make-instance 'rsb.protocol:user-time :key (keyword->bytes key) :timestamp (timestamp->unix-microseconds value)) (rsb.protocol:meta-data-user-times meta-data)))) ;; Encode causes (setf (fill-pointer causes) 0) (iter (for (origin . sequence-number) in (rsb:event-causes domain-object)) (vector-push-extend (make-instance 'rsb.serialization:event-id :sender-id (uuid:uuid-to-byte-array origin) :sequence-number sequence-number) causes)) (reinitialize-instance holder :sequence-number (rsb:event-sequence-number domain-object) :sender-id (uuid:uuid-to-byte-array (rsb:event-origin domain-object)) :scope (string->bytes (rsb:scope-string (rsb:event-scope domain-object))) :method (if (rsb:event-method domain-object) (keyword->bytes (rsb:event-method domain-object)) (load-time-value (nibbles:make-octet-vector 0))) :data (rsb:event-data domain-object)) (pb:pack* holder))) (defmethod decode ((transform rsb-event) (data simple-array)) (let+ (((&flet decode-event-id (id) (cons (uuid:byte-array-to-uuid (rsb.serialization:event-id-sender-id id)) (rsb.serialization:event-id-sequence-number id)))) ((&accessors-r/o (holder %transform-holder)) transform) ((&accessors-r/o (meta-data rsb.serialization:event-meta-data) (causes rsb.serialization:event-causes)) holder) ;; Create output event. (event (progn (setf (fill-pointer (rsb.protocol:meta-data-user-infos meta-data)) 0 (fill-pointer (rsb.protocol:meta-data-user-times meta-data)) 0 (fill-pointer causes) 0) (pb:unpack data holder) (make-instance 'rsb:event :sequence-number (rsb.serialization:event-sequence-number holder) :origin (uuid:byte-array-to-uuid (rsb.serialization:event-sender-id holder)) :scope (bytes->string (rsb.serialization:event-scope holder)) :method (unless (emptyp (rsb.serialization:event-method holder)) (bytes->keyword (rsb.serialization:event-method holder))) :data (rsb.serialization:event-data holder) :causes (map 'list #'decode-event-id (rsb.serialization:event-causes holder)) :create-timestamp? nil :intern-scope? t))) ((&flet process-timestamp (name value) (unless (zerop value) (setf (rsb:timestamp event name) (unix-microseconds->timestamp value)))))) ;; Fill fixed timestamps. (process-timestamp :create (rsb.protocol:meta-data-create-time meta-data)) (process-timestamp :send (rsb.protocol:meta-data-send-time meta-data)) (process-timestamp :receive (rsb.protocol:meta-data-receive-time meta-data)) (process-timestamp :deliver (rsb.protocol:meta-data-deliver-time meta-data)) ;; Add user meta-data. (iter (for item each (rsb.protocol:meta-data-user-infos meta-data)) (setf (rsb:meta-data event (bytes->keyword (rsb.protocol:user-info-key item))) (bytes->string (rsb.protocol:user-info-value item)))) ;; Add user timestamps. (iter (for time each (rsb.protocol:meta-data-user-times meta-data)) (setf (rsb:timestamp event (bytes->keyword (rsb.protocol:user-time-key time))) (unix-microseconds->timestamp (rsb.protocol:user-time-timestamp time)))) event)) ;;; Utility functions ;; (defvar *keyword-readtable* (let ((readtable (copy-readtable nil))) (setf (readtable-case readtable) :invert) readtable) "This readtable is used to print and read keywords. The goal is to get a natural mapping between Lisp keywords and corresponding strings for most cases.") (defun timestamp->unix-microseconds (timestamp) "Convert the `local-time:timestamp' instance TIMESTAMP into an integer which counts the number of microseconds since UNIX epoch." (+ (* 1000000 (local-time:timestamp-to-unix timestamp)) (* 1 (local-time:timestamp-microsecond timestamp)))) (defun unix-microseconds->timestamp (unix-microseconds) "Convert UNIX-MICROSECONDS to an instance of `local-time:timestamp'." (let+ (((&values unix-seconds microseconds) (floor unix-microseconds 1000000))) (local-time:unix-to-timestamp unix-seconds :nsec (* 1000 microseconds)))) (defun string->bytes (string) "Converter STRING into an octet-vector." (sb-ext:string-to-octets string :external-format :ascii)) (defun bytes->string (bytes) "Convert BYTES into a string." (sb-ext:octets-to-string bytes :external-format :ascii)) (declaim (ftype (function (keyword) nibbles:octet-vector) keyword->bytes)) (defun keyword->bytes (keyword) "Convert the name of KEYWORD into an octet-vector." (if (find #\: (symbol-name keyword)) (string->bytes (symbol-name keyword)) (let ((*readtable* *keyword-readtable*)) (string->bytes (princ-to-string keyword))))) (declaim (ftype (function (nibbles:octet-vector) keyword) bytes->keyword)) (defun bytes->keyword (bytes) "Converter BYTES into a keyword." (if (find (char-code #\:) bytes) (intern (bytes->string bytes) #.(find-package :keyword)) (let ((*package* #.(find-package :keyword)) (*readtable* *keyword-readtable*)) (read-from-string (bytes->string bytes)))))
8,347
Common Lisp
.lisp
190
39.705263
81
0.695855
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0809e587332869fb677797b9fc1397539a0586a2481b75b8082f65c0e951ad9d
37,760
[ -1 ]
37,761
package.lisp
open-rsx_rsbag-cl/compat/0.7/src/transform/package.lisp
;;; package.lisp --- Package definition for the transform module. ;; ;; Copyright (C) 2011-2018 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:defpackage :rsbag.transform (:use :cl :alexandria :let-plus :iterate :more-conditions) (:import-from :rsbag :make-versioned-name :with-versioned-packages) ;; Variables (:export :+rsb-schema-name+) ;; Conditions (:export :transform-error :transform-error-transform :encoding-error :transform-error-domain-object :decoding-error :transform-error-encoded) ;; Transform protocol (:export :transform-name :transform-format :decode :encode) (:documentation "This package contains the transformation protocol and infrastructure used in rsbag."))
1,571
Common Lisp
.lisp
53
27.056604
70
0.735586
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
17c04d5b4f44a02b9250e157ba1b3ad67223150600bccd20934c7d0314f58731
37,761
[ -1 ]
37,762
protocol.lisp
open-rsx_rsbag-cl/compat/0.7/src/transform/protocol.lisp
;;; protocol.lisp --- Protocol functions of the transform module. ;; ;; Copyright (C) 2011-2016 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:in-package :rsbag.transform) ;;; Transform protocol ;; (defgeneric transform-name (transform) (:documentation "Return an object identifying TRANSFORM.")) (defgeneric transform-format (transform) (:documentation "Return an object describing the encoding performed by TRANSFORM.")) (defgeneric encode (transform domain-object) (:documentation "Encode DOMAIN-OBJECT using TRANSFORM and return the result.")) (defgeneric decode (transform data) (:documentation "Decode DATA using TRANSFORM and return the decoded domain-object.")) ;;; Default behavior ;; (defmethod transform-name ((transform standard-object)) "Default behavior is to use the class name of TRANSFORM to identify TRANSFORM." (nth-value 0 (make-keyword (class-name (class-of transform))))) (defmethod encode :around ((transform t) (domain-object t)) "Establish a use-value restart and wrap arbitrary conditions in an `encoding-error' instance." (with-condition-translation (((error encoding-error) :transform transform :domain-object domain-object)) (restart-case (call-next-method) (use-value (value) :report (lambda (stream) (format stream "~@<Specify a value to use ~ instead of the result of the failed encoding.~@:>")) :interactive (lambda () (format *query-io* "~@<Enter replacement ~ value (unevaluated): ~@:>") (force-output *query-io*) (list (read *query-io*))) value)))) (defmethod decode :around ((transform t) (data t)) "Establish a use-value restart and wrap arbitrary conditions in a `decoding-error' instance." (with-condition-translation (((error decoding-error) :transform transform :encoded data)) (restart-case (call-next-method) (use-value (value) :report (lambda (stream) (format stream "~@<Specify a value to use ~ instead of the result of the failed decoding.~@:>")) :interactive (lambda () (format *query-io* "~@<Enter replacement ~ value (unevaluated): ~@:>") (force-output *query-io*) (list (read *query-io*))) value))))
3,055
Common Lisp
.lisp
86
32.5
70
0.713029
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
accaaef1c60b9f4cd5e99f6f270dfbe19ec2385c72553ab36af9332a3972112a
37,762
[ -1 ]
37,763
conditions.lisp
open-rsx_rsbag-cl/compat/0.7/src/transform/conditions.lisp
;;; conditions.lisp --- Conditions used in the transform module. ;; ;; Copyright (C) 2011, 2012 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:in-package :rsbag.transform) (define-condition transform-error (error) ((transform :initarg :transform :reader transform-error-transform :documentation "Stores the transform instance that was used in the failed transform operation.")) (:report (lambda (condition stream) (format stream "~@<A transformation involving the transform ~A ~ failed.~@:>" (transform-error-transform condition)))) (:documentation "Errors of this condition class and its subclasses are signaled when a transform fails.")) (define-condition encoding-error (transform-error chainable-condition) ((domain-object :initarg :domain-object :reader transform-error-domain-object :documentation "Stores the domain object the encoding of which failed.")) (:report (lambda (condition stream) (let ((*print-length* (or *print-length* 16))) (format stream "~@<The domain object ~S could not be encoded by ~ the transform ~A.~/more-conditions::maybe-print-cause/~@:>" (transform-error-domain-object condition) (transform-error-transform condition) condition)))) (:documentation "This error is signaled when the encoding of a domain object for storage in bag fails.")) (define-condition decoding-error (transform-error chainable-condition) ((encoded :initarg :encoded :reader transform-error-encoded :documentation "Stores the encoded data, the decoding of which failed.")) (:report (lambda (condition stream) (let ((*print-length* (or *print-length* 16))) (format stream "~@<The encoded value ~S could not be decoded by ~ the transform ~A.~/more-conditions::maybe-print-cause/~@:>" (transform-error-encoded condition) (transform-error-transform condition) condition)))) (:documentation "This error is signaled when the decoding of data, usually retrieved from a bag, fails."))
2,884
Common Lisp
.lisp
73
36
72
0.720698
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
fa5dadd857b318fbb4d98e27bfd1e31282bd5734563c03b30ea46ec1629d9e34
37,763
[ -1 ]
37,764
package.lisp
open-rsx_rsbag-cl/compat/0.8/src/transform/package.lisp
;;; package.lisp --- Package definition for the transform module. ;; ;; Copyright (C) 2011-2018 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:defpackage :rsbag.transform (:use :cl :alexandria :let-plus :iterate :more-conditions :nibbles) (:import-from :rsbag :make-versioned-name :with-versioned-packages) ;; Variables (:export :+rsb-schema-name+) ;; Conditions (:export :transform-error :transform-error-transform :encoding-error :transform-error-domain-object :decoding-error :transform-error-encoded) ;; Transform protocol (:export :transform-name :transform-format :decode :encode) (:documentation "This package contains the transformation protocol and infrastructure used in rsbag."))
1,584
Common Lisp
.lisp
54
26.703704
70
0.734868
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e94f0ee5259a7c535e7ccf70750b41d69b27f6048a03d35b39eac6da0f967e9e
37,764
[ -1 ]
37,767
package.lisp
open-rsx_rsbag-cl/compat/0.6/src/transform/package.lisp
;;; package.lisp --- Package definition for the transform module. ;; ;; Copyright (C) 2011-2018 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:defpackage :rsbag.transform (:use :cl :alexandria :let-plus :iterate :more-conditions) ;; Variables (:export :+rsb-schema-name+) ;; Conditions (:export :transform-error :transform-error-transform :encoding-error :transform-error-domain-object :decoding-error :transform-error-encoded) ;; Transform protocol (:export :transform-name :transform-format :decode :encode) (:documentation "This package contains the transformation protocol and infrastructure used in rsbag."))
1,494
Common Lisp
.lisp
50
27.38
70
0.736072
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
fd5c8f2cd70fa0cc886dd5efd2ae4f3c4c86af6cbb1cc8c1365a2cbac9fa7da8
37,767
[ -1 ]
37,768
protocol.lisp
open-rsx_rsbag-cl/compat/0.6/src/transform/protocol.lisp
;;; protocol.lisp --- Protocol functions of the transform module. ;; ;; Copyright (C) 2011-2016 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:in-package :rsbag.transform) ;;; Transform protocol ;; (defgeneric transform-name (transform) (:documentation "Return an object identifying TRANSFORM.")) (defgeneric transform-format (transform) (:documentation "Return an object describing the encoding performed by TRANSFORM.")) (defgeneric encode (transform domain-object) (:documentation "Encode DOMAIN-OBJECT using TRANSFORM and return the result.")) (defgeneric decode (transform data) (:documentation "Decode DATA using TRANSFORM and return the decoded domain-object.")) ;;; Default behavior ;; (defmethod transform-name ((transform standard-object)) "Default behavior is to use the class name of TRANSFORM to identify TRANSFORM." (nth-value 0 (make-keyword (class-name (class-of transform))))) (defmethod encode :around ((transform t) (domain-object t)) "Establish a use-value restart and wrap arbitrary conditions in an `encoding-error' instance." (handler-bind (((and error (not encoding-error)) #'(lambda (condition) (error 'encoding-error :transform transform :domain-object domain-object :cause condition)))) (restart-case (call-next-method) (use-value (value) :report (lambda (stream) (format stream "~@<Specify a value to use ~ instead of the result of the failed encoding.~@:>")) :interactive (lambda () (format *query-io* "~@<Enter replacement ~ value (unevaluated): ~@:>") (force-output *query-io*) (list (read *query-io*))) value)))) (defmethod decode :around ((transform t) (data t)) "Establish a use-value restart and wrap arbitrary conditions in a `decoding-error' instance." (handler-bind (((and error (not decoding-error)) #'(lambda (condition) (error 'decoding-error :transform transform :encoded data :cause condition)))) (restart-case (call-next-method) (use-value (value) :report (lambda (stream) (format stream "~@<Specify a value to use ~ instead of the result of the failed decoding.~@:>")) :interactive (lambda () (format *query-io* "~@<Enter replacement ~ value (unevaluated): ~@:>") (force-output *query-io*) (list (read *query-io*))) value))))
3,225
Common Lisp
.lisp
92
31.75
70
0.701186
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
87fe6afb94df93d1f68414ca817629bec39f403445ca3c55ef3acc0447e842ec
37,768
[ -1 ]
37,770
package.lisp
open-rsx_rsbag-cl/compat/0.4/src/transform/package.lisp
;;; package.lisp --- Package definition for the transform module. ;; ;; Copyright (C) 2011-2018 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:defpackage :rsbag.transform (:use :cl :alexandria :let-plus :iterate :more-conditions) ;; Transform protocol (:export :transform-name :decode :encode) (:documentation "This package contains the transformation protocol and infrastructure used in rsbag."))
1,242
Common Lisp
.lisp
38
30.657895
70
0.74
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d1655d16ca8cb632fe3e76f553974702ff9c660c9c4aa668e1184f0d38b4ec66
37,770
[ -1 ]
37,771
protocol.lisp
open-rsx_rsbag-cl/compat/0.4/src/transform/protocol.lisp
;;; protocol.lisp --- Protocol functions of the transform module. ;; ;; Copyright (C) 2011-2016 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:in-package :rsbag.transform) ;;; Transform protocol ;; (defgeneric transform-name (transform) (:documentation "Return a keyword identifying TRANSFORM.")) (defgeneric encode (transform domain-object) (:documentation "Encode DOMAIN-OBJECT using TRANSFORM and return the result.")) (defgeneric decode (transform data) (:documentation "Decode DATA using TRANSFORM and return the decoded domain-object.")) ;;; Default behavior ;; (defmethod transform-name ((transform standard-object)) "Default behavior is to use the class name of TRANSFORM to identify TRANSFORM." (nth-value 0 (make-keyword (class-name (class-of transform)))))
1,603
Common Lisp
.lisp
42
36.452381
70
0.756774
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f9eecacdf308389c6a97a2285cb3ac57d2c00c03224316f3d30cf455ca6acd06
37,771
[ -1 ]
37,772
rsb-event.lisp
open-rsx_rsbag-cl/compat/0.4/src/transform/rsb-event.lisp
;;; rsb-event.lisp --- (De)serialization of RSB events. ;; ;; Copyright (C) 2011-2016 Jan Moringen ;; ;; Author: Jan Moringen <[email protected]> ;; ;; This file may be licensed under the terms of the GNU Lesser General ;; Public License Version 3 (the ``LGPL''), or (at your option) any ;; later version. ;; ;; Software distributed under the License is distributed on an ``AS ;; IS'' basis, WITHOUT WARRANTY OF ANY KIND, either express or ;; implied. See the LGPL for the specific language governing rights ;; and limitations. ;; ;; You should have received a copy of the LGPL along with this ;; program. If not, go to http://www.gnu.org/licenses/lgpl.html or ;; write to the Free Software Foundation, Inc., 51 Franklin Street, ;; Fifth Floor, Boston, MA 02110-1301, USA. ;; ;; The development of this software was supported by: ;; CoR-Lab, Research Institute for Cognition and Robotics ;; Bielefeld University (cl:in-package :rsbag.transform) (defclass rsb-event () ((wire-schema :initarg :wire-schema :type keyword :reader transform-wire-schema :documentation "Stores the associated wire-schema of (de)serialized events.") (holder :reader %transform-holder :initform (make-instance 'rsb.serialization:event) :documentation "Stores a data-holder instance that is reused during (de)serialization for efficiency reasons.")) (:default-initargs :wire-schema (required-argument :wire-schema)) (:documentation "Instances of this transform class (de)serialize RSB events from/to octet vectors.")) (defmethod transform-name ((transform rsb-event)) (list (make-keyword (class-name (class-of transform))) (transform-wire-schema transform))) (defmethod encode ((transform rsb-event) (domain-object rsb:event)) (let+ (((&accessors-r/o (holder %transform-holder) (wire-schema transform-wire-schema)) transform) (meta-data (rsb.serialization::event-meta-data holder)) ((&flet process-timestamp (name) (let ((value (rsb:timestamp domain-object name))) (if value (timestamp->unix-microseconds value) 0))))) ;; Prepare meta-data container. (reinitialize-instance meta-data :create-time (process-timestamp :create) :send-time (process-timestamp :send) :receive-time (process-timestamp :receive) :deliver-time (process-timestamp :deliver)) (setf (fill-pointer (rsb.protocol::meta-data-user-infos meta-data)) 0 (fill-pointer (rsb.protocol::meta-data-user-times meta-data)) 0) ;; Add user meta-data. (iter (for (key value) on (rsb:event-meta-data domain-object) :by #'cddr) (vector-push-extend (make-instance 'rsb.protocol::user-info :key (keyword->bytes key) :value (string->bytes value)) (rsb.protocol::meta-data-user-infos meta-data))) ;; Add user timestamps. (iter (for (key value) on (rsb:event-timestamps domain-object) :by #'cddr) (unless (member key '(:create :send :receive :deliver)) (vector-push-extend (make-instance 'rsb.protocol::user-time :key (keyword->bytes key) :timestamp (timestamp->unix-microseconds value)) (rsb.protocol::meta-data-user-times meta-data)))) (reinitialize-instance holder :sequence-number (rsb:event-sequence-number domain-object) :sender-id (uuid:uuid-to-byte-array (rsb:event-origin domain-object)) :scope (string->bytes (rsb:scope-string (rsb:event-scope domain-object))) :method (if (rsb:event-method domain-object) (string->bytes (rsb:event-method domain-object)) (load-time-value (nibbles:make-octet-vector 0))) :wire-schema (wire-schema->bytes wire-schema) :data (rsb:event-data domain-object)) (pb:pack* holder))) (defmethod decode ((transform rsb-event) (data simple-array)) (pb:unpack data (%transform-holder transform)) (let+ (((&accessors-r/o (holder %transform-holder)) transform) (meta-data (rsb.serialization::event-meta-data holder)) ;; Create output event. (event (make-instance 'rsb:event :sequence-number (rsb.serialization::event-sequence-number holder) :origin (uuid:byte-array-to-uuid (rsb.serialization::event-sender-id holder)) :scope (bytes->string (rsb.serialization::event-scope holder)) :method nil :data (rsb.serialization::event-data holder) :create-timestamp? nil)) ((&flet process-timestamp (name value) (unless (zerop value) (setf (rsb:timestamp event name) (unix-microseconds->timestamp value)))))) ;; Fill fixed timestamps. (process-timestamp :create (rsb.protocol::meta-data-create-time meta-data)) (process-timestamp :send (rsb.protocol::meta-data-send-time meta-data)) (process-timestamp :receive (rsb.protocol::meta-data-receive-time meta-data)) (process-timestamp :deliver (rsb.protocol::meta-data-deliver-time meta-data)) ;; Add user meta-data. (iter (for item each (rsb.protocol::meta-data-user-infos meta-data)) (setf (rsb:meta-data event (bytes->keyword (rsb.protocol::user-info-key item))) (bytes->string (rsb.protocol::user-info-key item)))) ;; Add user timestamps. (iter (for time each (rsb.protocol::meta-data-user-times meta-data)) (setf (rsb:timestamp event (bytes->keyword (rsb.protocol::user-time-key time))) (unix-microseconds->timestamp (rsb.protocol::user-time-timestamp time)))) event)) ;;; Utility functions ;; (defvar *keyword-readtable* (let ((readtable (copy-readtable nil))) (setf (readtable-case readtable) :invert) readtable) "This readtable is used to print and read keywords. The goal is to get a natural mapping between Lisp keywords and corresponding strings for most cases.") (defun timestamp->unix-microseconds (timestamp) "Convert the `local-time:timestamp' instance TIMESTAMP into an integer which counts the number of microseconds since UNIX epoch." (+ (* 1000000 (local-time:timestamp-to-unix timestamp)) (* 1 (local-time:timestamp-microsecond timestamp)))) (defun unix-microseconds->timestamp (unix-microseconds) "Convert UNIX-MICROSECONDS to an instance of `local-time:timestamp'." (let+ (((&values unix-seconds microseconds) (floor unix-microseconds 1000000))) (local-time:unix-to-timestamp unix-seconds :nsec (* 1000 microseconds)))) (defun string->bytes (string) "Converter STRING into an octet-vector." (sb-ext:string-to-octets string :external-format :ascii)) (defun bytes->string (bytes) "Convert BYTES into a string." (sb-ext:octets-to-string bytes :external-format :ascii)) (declaim (ftype (function (keyword) nibbles:octet-vector) keyword->bytes)) (defun keyword->bytes (keyword) "Convert the name of KEYWORD into an octet-vector." (if (find #\: (symbol-name keyword)) (string->bytes (symbol-name keyword)) (let ((*readtable* *keyword-readtable*)) (string->bytes (princ-to-string keyword))))) (declaim (ftype (function (nibbles:octet-vector) keyword) bytes->keyword)) (defun bytes->keyword (bytes) "Converter BYTES into a keyword." (if (find (char-code #\:) bytes) (intern (bytes->string bytes) #.(find-package :keyword)) (let ((*package* #.(find-package :keyword)) (*readtable* *keyword-readtable*)) (read-from-string (bytes->string bytes))))) (defun wire-schema->bytes (wire-schema) "Convert WIRE-SCHEMA to an ASCII representation stored in an octet-vector." (keyword->bytes wire-schema)) (defun bytes->wire-schema (bytes) "Return a keyword representing the wire-schema encoded in bytes." (bytes->keyword bytes))
7,689
Common Lisp
.lisp
177
39.536723
81
0.703847
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3ec61b17d8963deef34818cfab6a9bdca1dac8621ba712aadf47eaacce4c5fbb
37,772
[ -1 ]
37,773
rsbag-builder.asd
open-rsx_rsbag-cl/rsbag-builder.asd
;;;; rsbag-builder.asd --- Builder support for RSBag objects. ;;;; ;;;; Copyright (C) 2015, 2016, 2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag-builder-system (:use #:cl #:asdf)) (cl:in-package #:rsbag-builder-system) #.(progn (load (merge-pathnames "rsbag.asd" *load-truename*)) (values)) (asdf:defsystem "rsbag-builder" :description "Builder support for RSBag objects such as bags and channels." :license "LGPLv3" ; see COPYING file for details. :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(rsbag-system:version/string) :depends-on ("alexandria" "let-plus" (:version "architecture.builder-protocol" "0.3") (:version "rsbag" #.(rsbag-system:version/string))) :components ((:module "builder" :pathname "src" :components ((:file "builder")))) :in-order-to ((test-op (test-op "rsbag-builder/test")))) (asdf:defsystem "rsbag-builder/test" :description "Unit tests for the rsbag-builder system." :license "LGPLv3" ; see COPYING file for details. :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(rsbag-system:version/string) :depends-on ((:version "lift" "1.7.1") (:version "architecture.builder-protocol/test" "0.3") (:version "rsbag-builder" #.(rsbag-system:version/string)) (:version "rsbag/test" #.(rsbag-system:version/string))) :components ((:module "builder" :pathname "test" :components ((:file "builder")))) :perform (test-op (operation component) (funcall (find-symbol "RUN-TESTS" :lift) :config (funcall (find-symbol "LIFT-RELATIVE-PATHNAME" :lift) "lift-builder.config"))))
2,190
Common Lisp
.asd
44
41.636364
96
0.583568
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cd6a3af2e081c64ef2361e4140dec0598d9bebabec6692dc2c408378ec820565
37,773
[ -1 ]
37,774
rsbag-tidelog.asd
open-rsx_rsbag-cl/rsbag-tidelog.asd
;;;; rsbag-tidelog.asd --- System definition for TIDELog backend of rsbag. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag-tidelog-system (:use #:cl #:asdf)) (cl:in-package #:rsbag-tidelog-system) #.(progn (load (merge-pathnames "rsbag.asd" *load-truename*)) (values)) (asdf:defsystem "rsbag-tidelog" :description "TIDE log file format backend for rsbag." :license "LGPLv3" ; see COPYING file for details. :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(rsbag-system:version/string) :depends-on ((:version "rsbag" #.(rsbag-system:version/string))) :components ((:module "tidelog" :pathname "src/backend/tidelog" :serial t :components ((:file "package") (:file "variables") (:file "conditions") (:file "protocol") (:file "util") (:file "generator") (:file "macros") (:file "spec") (:file "io") (:file "index-vector") (:file "index") (:file "file") (:file "repair")))) :in-order-to ((test-op (test-op "rsbag-tidelog/test")))) (asdf:defsystem "rsbag-tidelog/test" :description "Unit tests for the rsbag-tidelog system." :license "LGPLv3" ; see COPYING file for details. :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(rsbag-system:version/string) :depends-on ((:version "lift" "1.7.1") (:version "rsbag-tidelog" #.(rsbag-system:version/string)) (:version "rsbag/test" #.(rsbag-system:version/string))) :components ((:module "tidelog" :pathname "test/backend/tidelog" :serial t :components ((:file "package") (:file "io") (:file "file") (:file "repair")))) :perform (test-op (operation component) (funcall (find-symbol "RUN-TESTS" :lift) :config (funcall (find-symbol "LIFT-RELATIVE-PATHNAME" :lift) "lift-tidelog.config"))))
2,791
Common Lisp
.asd
57
35.017544
87
0.49042
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3caf3b8e85e64c74fcf273682621ee0837529d0bd0909ed096eafe526881a432
37,774
[ -1 ]
37,775
rsbag-elan.asd
open-rsx_rsbag-cl/rsbag-elan.asd
;;;; rsbag-elan.asd --- System definition for ELAN backend of rsbag. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag-elan-system (:use #:cl #:asdf)) (cl:in-package #:rsbag-elan-system) #.(progn (load (merge-pathnames "rsbag.asd" *load-truename*)) (values)) (asdf:defsystem "rsbag-elan" :description "Elan file format backend for rsbag." :license "LGPLv3" ; see COPYING file for details. :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(rsbag-system:version/string) :depends-on ((:version "xml.location" "0.2.0") (:version "xml.location-and-local-time" "0.2.0") (:version "rsbag" #.(rsbag-system:version/string))) :components ((:module "elan" :pathname "src/backend/elan" :serial t :components ((:file "package") (:file "types") (:file "util") (:file "variables") (:file "xml") (:file "file")))) :in-order-to ((test-op (test-op "rsbag-elan/test")))) (asdf:defsystem "rsbag-elan/test" :description "Unit tests for the rsbag-elan system." :license "LGPLv3" ; see COPYING file for details. :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(rsbag-system:version/string) :depends-on ((:version "lift" "1.7.1") (:version "rsbag-elan" #.(rsbag-system:version/string)) (:version "rsbag/test" #.(rsbag-system:version/string))) :components ((:module "elan" :pathname "test/backend/elan" :serial t :components ((:file "package")))) :perform (test-op (operation component) (funcall (find-symbol "RUN-TESTS" :lift) :config (funcall (find-symbol "LIFT-RELATIVE-PATHNAME" :lift) "lift-elan.config"))))
2,349
Common Lisp
.asd
49
37.469388
89
0.540245
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7423dde4e5ee511044eb6183f7b6f967dd489c1da4046ee50fe53cd6a157551b
37,775
[ -1 ]
37,776
sbclrc
open-rsx_rsbag-cl/sbclrc
(setf *terminal-io* (make-two-way-stream (make-synonym-stream '*standard-input*) (make-synonym-stream '*standard-output*))) (defun load-system (system) (let ((*compile-verbose* nil) (*compile-print* nil) (*load-verbose* nil) (*load-print* nil)) (ql:quickload system :verbose nil :explain nil :prompt nil)))
341
Common Lisp
.cl
9
34.222222
65
0.661631
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cfc8b19a176282a5ad922b1823fb89c84c3fc3e7b8f72c644e61faa2a55f3922
37,776
[ -1 ]
37,777
sbcl.cmake.in
open-rsx_rsbag-cl/sbcl.cmake.in
SET(ENV{CC} "@CMAKE_C_COMPILER@") SET(ENV{SBCL_HOME} "@SBCL_HOME@") SET(ENV{CL_SOURCE_REGISTRY} "@CL_SOURCE_REGISTRY@") SET(ENV{ASDF_OUTPUT_TRANSLATIONS} "@ASDF_OUTPUT_TRANSLATIONS@") EXECUTE_PROCESS(COMMAND "@SBCL_EXECUTABLE@" @LISP_RUNTIME_OPTIONS@ --noinform --disable-debugger --no-sysinit --no-userinit @LISP_INIT@ --load "@CMAKE_CURRENT_SOURCE_DIR@/sbclrc" @DO@ WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@" @REDIRECTIONS@ RESULT_VARIABLE RESULT) IF(NOT ${RESULT} EQUAL 0) MESSAGE(FATAL_ERROR "Failed to execute Lisp process @NAME@") ENDIF()
895
Common Lisp
.cl
18
32.555556
76
0.46347
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d8510d9175777860e0e2be2cb692b356cf97430db3f4e2ba45862fbece64c6f1
37,777
[ -1 ]
37,782
lift-tidelog.config
open-rsx_rsbag-cl/lift-tidelog.config
;;; Configuration for LIFT tests ;; Settings (:print-length 10) (:print-level 5) (:print-test-case-names t) ;; Suites to run (rsbag.backend.tidelog.test:backend-tidelog-root) ;; Report properties (:report-property :title "rsbag-tidelog | Test Results") (:report-property :relative-to rsbag-tidelog-test) (:report-property :full-pathname "test-report-tidelog.html/") (:report-property :format :html) (:report-property :if-exists :supersede) (:report-property :style-sheet "test-style.css") (:build-report) (:report-property :full-pathname "test-results-tidelog.xml") (:report-property :format :junit) (:report-property :if-exists :supersede) (:build-report) (:report-property :format :describe) (:report-property :full-pathname *standard-output*) (:build-report)
818
Common Lisp
.l
22
35.909091
61
0.718987
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6ab93a9723d143e188ee7d22c0d90d91601b0062648a18f83fbbeef3e20491ac
37,782
[ -1 ]
37,786
.travis.yml
open-rsx_rsbag-cl/.travis.yml
language: lisp dist: xenial env: PREFIX="$(pwd)/sbcl" SBCL_HOME="$(pwd)/sbcl/lib/sbcl" SBCL="$(pwd)/sbcl/bin/sbcl" SBCL_OPTIONS="--noinform --no-userinit" install: - curl -L "${SBCL_DOWNLOAD_URL}" | tar -xj - ( cd sbcl-* && INSTALL_ROOT="${PREFIX}" sh install.sh ) - curl -o cl "${CL_LAUNCH_DOWNLOAD_URL}" - chmod +x cl - curl -o quicklisp.lisp "${QUICKLISP_DOWNLOAD_URL}" - ./cl -L quicklisp.lisp '(quicklisp-quickstart:install)' script: - ( cd "${HOME}/quicklisp/local-projects" && git clone https://github.com/scymtym/cl-protobuf && git clone https://github.com/scymtym/iterate-sequence && git clone https://github.com/open-rsx/rsb-cl ) - ./cl -S '(:source-registry (:directory "'$(pwd)'") :ignore-inherited-configuration)' -Q -s cl-protobuf -s rsbag/test -s rsbag-builder/test -s rsbag-tidelog/test -s rsbag-elan/test '(or (mapc (function asdf:test-system) (list :rsbag/test :rsbag-builder/test :rsbag-tidelog/test :rsbag-elan/test)) (uiop:quit -1))'
1,170
Common Lisp
.l
34
27.088235
85
0.583039
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
841c44e09f0a712bf54eaa9b53c11b1954f66ab99d6ee531eef80f65cc9796be
37,786
[ -1 ]
37,787
lift-builder.config
open-rsx_rsbag-cl/lift-builder.config
;;; Configuration for LIFT tests ;; Settings (:print-length 100) (:print-level 50) (:print-test-case-names t) ;; Suites to run (rsbag.builder.test:rsbag-builder-root) ;; Report properties (:report-property :title "rsbag-builder | Test Results") (:report-property :relative-to rsbag-builder-test) (:report-property :full-pathname "test-report-builder.html/") (:report-property :format :html) (:report-property :if-exists :supersede) (:report-property :style-sheet "test-style.css") (:build-report) (:report-property :full-pathname "test-results-builder.xml") (:report-property :format :junit) (:report-property :if-exists :supersede) (:build-report) (:report-property :format :describe) (:report-property :full-pathname *standard-output*) (:build-report)
810
Common Lisp
.l
22
35.545455
61
0.717391
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0183799f678868e17c10ac74bddba7b828a669a8a750167fe6dbbc9e1cdb76fe
37,787
[ -1 ]
37,788
lift-elan.config
open-rsx_rsbag-cl/lift-elan.config
;;; Configuration for LIFT tests ;; Settings (:print-length 10) (:print-level 5) (:print-test-case-names t) ;; Suites to run (rsbag.backend.elan.test:backend-elan-root) ;; Report properties (:report-property :title "rsbag-elan | Test Results") (:report-property :relative-to rsbag-elan-test) (:report-property :full-pathname "test-report-elan.html/") (:report-property :format :html) (:report-property :if-exists :supersede) (:report-property :style-sheet "test-style.css") (:build-report) (:report-property :full-pathname "test-results-elan.xml") (:report-property :format :junit) (:report-property :if-exists :supersede) (:build-report) (:report-property :format :describe) (:report-property :full-pathname *standard-output*) (:build-report)
800
Common Lisp
.l
22
35.090909
58
0.712435
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f0c44a47e03da85a7d22f2a6600097ce00946425b1c2a637005c759d5dd2b187
37,788
[ -1 ]
37,913
3d.l
giorgianb_lray-tracer/3d.l
(defpackage "3D" (:use "COMMON-LISP") (:export "3D-VECTOR" "3D-VECTOR-X" "3D-VECTOR-Y" "3D-VECTOR-Z" "WITH-3D-VECTOR" "MAGNITUDE" "UNIT-VECTOR" "ADD" "SUBTRACT" "MULTIPLY" "DIVIDE" "DOT-PRODUCT" "CROSS-PRODUCT" "ANGLE" "3D-POINT" "3D-POINT-X" "3D-POINT-Y" "3D-POINT-Z" "WITH-3D-POINT" "DISTANCE" "PLANE" "PLANE-P1" "PLANE-P2" "PLANE-P3" "WITH-PLANE" "INTERSECT" "NORMAL" "SPHERE" "WITH-SPHERE" "SPHERE-CENTER" "SPHERE-RADIUS")) (in-package 3d) (defclass 3d-vector () ((x :type number :reader 3d-vector-x :initarg :x) (y :type number :reader 3d-vector-y :initarg :y) (z :type number :reader 3d-vector-z :initarg :z))) (defmacro with-3d-vector (vars v &body body) (declare (list vars body)) (if (/= (length vars) 3) (error "Variables specification must specify three variables.")) (let ((v-sym (gensym))) `(let* ((,v-sym ,v) (,(first vars) (3d-vector-x ,v-sym)) (,(second vars) (3d-vector-y ,v-sym)) (,(third vars) (3d-vector-z ,v-sym))) (declare (3d-vector ,v-sym)) ,@body))) (defmethod magnitude ((v 3d-vector)) (sqrt (+ (expt (3d-vector-x v) 2) (expt (3d-vector-y v) 2) (expt (3d-vector-z v) 2)))) (defmethod unit-vector ((v 3d-vector)) (let ((d (magnitude v))) (make-instance '3d-vector :x (/ (3d-vector-x v) d) :y (/ (3d-vector-y v) d) :z (/ (3d-vector-z v) d)))) (defmethod add ((a 3d-vector) (b 3d-vector)) (with-3d-vector (ax ay az) a (with-3d-vector (bx by bz) b (make-instance '3d-vector :x (+ ax bx) :y (+ ay by) :z (+ az bz))))) (defmethod subtract ((a 3d-vector) (b 3d-vector)) (with-3d-vector (ax ay az) a (with-3d-vector (bx by bz) b (make-instance '3d-vector :x (- ax bx) :y (- ay by) :z (- az bz))))) (defmethod multiply ((v 3d-vector) (k number)) (with-3d-vector (x y z) v (make-instance '3d-vector :x (* x k) :y (* y k) :z (* z k)))) (defmethod divide ((v 3d-vector) (k number)) (with-3d-vector (x y z) v (make-instance '3d-vector :x (/ x k) :y (/ y k) :z (/ z k)))) (defmethod dot-product ((a 3d-vector) (b 3d-vector)) (with-3d-vector (ax ay az) a (with-3d-vector (bx by bz) b (+ (* ax bx) (* ay by) (* az bz))))) (defmethod cross-product ((a 3d-vector) (b 3d-vector)) (with-3d-vector (ax ay az) a (with-3d-vector (bx by bz) b (make-instance '3d-vector :x (- (* ay bz) (* az by)) :y (- (* az bx) (* ax bz)) :z (- (* ax by) (* ay bx)))))) (defmethod angle ((a 3d-vector) (b 3d-vector)) (acos (/ (dot-product a b) (* (magnitude a) (magnitude b))))) (defclass 3d-point () ((x :type number :reader 3d-point-x :initarg :x) (y :type number :reader 3d-point-y :initarg :y) (z :type number :reader 3d-point-z :initarg :z))) (defmacro with-3d-point (vars p &body body) (declare (list vars body)) (if (/= (length vars) 3) (error "Variable specification must specify 3 variables.")) (let ((p-sym (gensym))) `(let* ((,p-sym ,p) (,(first vars) (3d-point-x ,p-sym)) (,(second vars) (3d-point-y ,p-sym)) (,(third vars) (3d-point-z ,p-sym))) (declare (3d-point ,p-sym)) ,@body))) (defmethod distance ((a 3d-point) (b 3d-point)) (with-3d-point (ax ay az) a (with-3d-point (bx by bz) b (sqrt (+ (expt (- ax bx) 2) (expt (- ay by) 2) (expt (- az bz) 2)))))) (defclass plane () ((p1 :type 3d-point :reader plane-p1 :initarg :p1) (p2 :type 3d-point :reader plane-p2 :initarg :p2) (p3 :type 3d-point :reader plane-p3 :initarg :p3))) (defmacro with-plane (vars p &body body) (declare (list vars body)) (if (/= (length vars) 3) (error "Variable specification must specify 3 variables.")) (let ((p-sym (gensym))) `(let* ((,p-sym ,p) (,(first vars) (plane-p1 ,p-sym)) (,(second vars) (plane-p2 ,p-sym)) (,(third vars) (plane-p3 ,p-sym))) (declare (plane ,p-sym)) ,@body))) (defun 3d-point-to-3d-vector (p) (declare (3d-point p)) (with-3d-point (x y z) p (make-instance '3d-vector :x x :y y :z z))) (defmethod intersect ((p plane) (vp 3d-point) (v 3d-vector)) (let ((n (normal p nil))) (unless (zerop (dot-product n v)) (let ((i (solve-plane-intersect (plane-p1 p) n vp v))) (make-instance '3d-point :x (+ (3d-point-x vp) (* (3d-vector-x v) i)) :y (+ (3d-point-y vp) (* (3d-vector-y v) i)) :z (+ (3d-point-z vp) (* (3d-vector-z v) i))))))) (defmethod normal ((p plane) pt) (declare (ignore pt)) (with-plane (p1 p2 p3) p (let ((a (3d-point-to-3d-vector p1)) (b (3d-point-to-3d-vector p2)) (c (3d-point-to-3d-vector p3))) (unit-vector (cross-product (subtract a b) (subtract a c)))))) (defun solve-plane-intersect (a n o v) (declare (3d-point a o) (3d-vector n v)) (let ((ax (3d-point-x a)) (ay (3d-point-y a)) (az (3d-point-z a)) (nx (3d-vector-x n)) (ny (3d-vector-y n)) (nz (3d-vector-z n)) (ox (3d-point-x o)) (oy (3d-point-y o)) (oz (3d-point-z o)) (dx (3d-vector-x v)) (dy (3d-vector-y v)) (dz (3d-vector-z v))) (/ (- (+ (* nx ax) (* ny ay) (* nz az)) (+ (* nx ox) (* ny oy) (* nz oz))) (+ (* nx dx) (* ny dy) (* nz dz))))) (defclass sphere () ((center :type 3d-point :reader sphere-center :initarg :center) (radius :type number :reader sphere-radius :initarg :radius))) (defmacro with-sphere (vars s &body body) (declare (list vars body)) (if (/= (length vars) 2) (error "Variable specification must specify 2 variables!")) (let ((s-sym (gensym))) `(let* ((,s-sym ,s) (,(first vars) (sphere-center ,s-sym)) (,(second vars) (sphere-radius ,s-sym))) (declare (sphere ,s-sym)) ,@body))) (defmethod intersect ((s sphere) (vp 3d-point) (v 3d-vector)) (with-sphere (c r) s (with-3d-vector (x y z) v (let ((n (min-root (+ (expt x 2) (expt y 2) (expt z 2)) (* 2 (+ (* (- (3d-point-x vp) (3d-point-x c)) x) (* (- (3d-point-y vp) (3d-point-y c)) y) (* (- (3d-point-z vp) (3d-point-z c)) z))) (+ (expt (- (3d-point-x vp) (3d-point-x c)) 2) (expt (- (3d-point-y vp) (3d-point-y c)) 2) (expt (- (3d-point-z vp) (3d-point-z c)) 2) (- (expt r 2)))))) (if n (make-instance '3d-point :x (+ (3d-point-x vp) (* n x)) :y (+ (3d-point-y vp) (* n y)) :z (+ (3d-point-z vp) (* n z)))))))) (defmethod normal ((s sphere) (pt 3d-point)) (with-sphere (c r) s (declare (ignore r)) (unit-vector (make-instance '3d-vector :x (- (3d-point-x c) (3d-point-x pt)) :y (- (3d-point-y c) (3d-point-y pt)) :z (- (3d-point-z c) (3d-point-z pt)))))) (defun min-root (a b c) (declare (number a b c)) (if (zerop a) (/ (- c) b) (let ((disc (- (expt b 2) (* 4 a c)))) (unless (minusp disc) (let ((discrt (sqrt disc))) (min (/ (+ (- b) discrt) (* 2 a)) (/ (- (- b) discrt) (* 2 a))))))))
6,975
Common Lisp
.l
198
30.510101
70
0.558109
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8a26948688b7ef3816990c066b0b8f702457dd18292de7af39530b50bcc06fd7
37,913
[ -1 ]
37,914
ray-tracing.l
giorgianb_lray-tracer/ray-tracing.l
(defun sq (x) (* x x)) (defun mag (x y z) (sqrt (+ (sq x) (sq y) (sq z)))) (defun unit-vector (x y z) (let ((d (mag x y z))) (values (/ x d) (/ y d) (/ z d)))) (defstruct (point (:conc-name nil)) x y z) (defun distance (p1 p2) (mag (- (x p1) (x p2)) (- (y p1) (y p2)) (- (z p1) (z p2)))) (defun minroot (a b c) (if (zerop a) (/ (- c) b) (let ((disc (- (sq b) (* 4 a c)))) (unless (minusp disc) (let ((discrt (sqrt disc))) (min (/ (+ (- b) discrt) (* 2 a)) (/ (- (- b) discrt) (* 2 a)))))))) (defstruct surface color) (defparameter *world* nil) (defconstant eye (make-point :x 0 :y 0 :z 200)) (defun tracer (pathname &optional (res 1)) (with-open-file (p pathname :direction :output) (format p "P2 ~A ~A 255" (* res 100) (* res 100)) (let ((inc (/ res))) (do ((y -50 (+ y inc))) ((< (- 50 y) inc)) (do ((x -50 (+ x inc))) ((< (- 50 x) inc)) (print (color-at x y) p)))))) (defun color-at (x y) (multiple-value-bind (xr yr zr) (unit-vector (- x (x eye)) (- y (y eye)) (- 0 (z eye))) (round (* (sendray eye xr yr zr) 256)))) (defun sendray (pt xr yr zr) (multiple-value-bind (s int) (first-hit pt xr yr zr) (if s (* (lambert s int xr yr zr) (surface-color s)) 0))) (defun first-hit (pt xr yr zr) (let (surface hit dist) (dolist (s *world*) (let ((h (intersect s pt xr yr zr))) (when h (let ((d (distance h pt))) (when (or (null dist) (< d dist)) (setf surface s hit h dist d)))))) (values surface hit))) (defun lambert (s int xr yr zr) (multiple-value-bind (xn yn zn) (normal s int) (max 0 (+ (* xr xn) (* yr yn) (* zr zn))))) (defstruct (sphere (:include surface)) radius center) (defun defsphere (x y z r c) (let ((s (make-sphere :radius r :center (make-point :x x :y y :z z) :color c))) (push s *world*) s)) (defun intersect (s pt xr yr zr) (funcall (typecase s (sphere #'sphere-intersect) (cube #'cube-intersect)) s pt xr yr zr)) (defun sphere-intersect (s pt xr yr zr) (let* ((c (sphere-center s)) (n (minroot (+ (sq xr) (sq yr) (sq zr)) (* 2 (+ (* (- (x pt) (x c)) xr) (* (- (y pt) (y c)) yr) (* (- (z pt) (z c)) zr))) (+ (sq (- (x pt) (x c))) (sq (- (y pt) (y c))) (sq (- (z pt) (z c))) (- (sq (sphere-radius s))))))) (if n (make-point :x (+ (x pt) (* n xr)) :y (+ (y pt) (* n yr)) :z (+ (z pt) (* n zr)))))) (defun normal (s pt) (funcall (typecase s (sphere #'sphere-normal) (cube #'cube-normal)) s pt)) (defun sphere-normal (s pt) (let ((c (sphere-center s))) (unit-vector (- (x c) (x pt)) (- (y c) (y pt)) (- (z c) (z pt))))) (defun ray-test (&optional (res 1)) (setf *world* nil) ; (defsphere 0 -300 -1200 200 .8) ; (defsphere -80 -150 -1200 200 .7) ; (defsphere 70 -100 -1200 200 .9) (defcube 70 -100 -1200 200 .9) (do ((x -2 (1+ x))) ((> x 2)) (do ((z 2 (1+ z))) ((> z 7)) ; (defsphere (* x 200) 300 (* z -400) 40 .75) (defcube (* x 200) 300 (* z -400) 60 .75))) (tracer (make-pathname :name "pic.pgm") res)) (defstruct (cube (:include surface)) side-length center) (defun defcube (x y z s c) (let ((cube (make-cube :side-length s :center (make-point :x x :y y :z z) :color c))) (push cube *world*))) (defun cube-intersect (c pt xr yr zr) (let (points) (dolist (face (list #'cube-bottom-intersect #'cube-top-intersect #'cube-left-intersect #'cube-right-intersect #'cube-front-intersect #'cube-back-intersect) (closest-to pt points)) (let ((p (funcall face c pt xr yr zr))) (if (and p (not (cube-edge-point-p c p pt))) (push p points)))))) (defun cube-normal (cube pt) (multiple-value-bind (x-min x-max y-min y-max z-min z-max) (cube-bounds cube) (cond ((= (x pt) x-min) (unit-vector 1 0 0)) ((= (x pt) x-max) (unit-vector -1 0 0)) ((= (y pt) y-min) (unit-vector 0 1 0)) ((= (y pt) y-max) (unit-vector 0 -1 0)) ((= (z pt) z-min) (unit-vector 0 0 1)) ((= (z pt) z-max) (unit-vector 0 0 -1))))) (defun cube-bounds (cube &optional (origin (make-point :x 0 :y 0 :z 0))) (let ((off (/ (cube-side-length cube) 2)) (c (cube-center cube))) (values (- (x c) off (x origin)) (+ (x c) (- off (x origin))) (- (y c) off (y origin)) (+ (y c) (- off (y origin))) (- (z c) off (z origin)) (+ (z c) (- off (z origin)))))) (defun cube-left-intersect (c pt xr yr zr) (unless (zerop xr) (multiple-value-bind (x-min x-max y-min y-max z-min z-max) (cube-bounds c pt) (let ((scale (/ x-min xr))) (if (and (<= y-min (* yr scale) y-max) (<= z-min (* zr scale) z-max)) (make-point :x (+ x-min (x pt)) :y (+ (* yr scale) (y pt)) :z (+ (* zr scale) (z pt)))))))) (defun cube-right-intersect (c pt xr yr zr) (unless (zerop xr) (multiple-value-bind (x-min x-max y-min y-max z-min z-max) (cube-bounds c pt) (let ((scale (/ x-max xr))) (if (and (<= y-min (* yr scale) y-max) (<= z-min (* zr scale) z-max)) (make-point :x (+ x-max (x pt)) :y (+ (* yr scale) (y pt)) :z (+ (* zr scale) (z pt)))))))) (defun cube-bottom-intersect (c pt xr yr zr) (unless (zerop yr) (multiple-value-bind (x-min x-max y-min y-max z-min z-max) (cube-bounds c pt) (let ((scale (/ y-min yr))) (if (and (<= x-min (* xr scale) x-max) (<= z-min (* zr scale) z-max)) (make-point :x (+ (* xr scale) (x pt)) :y (+ y-min (y pt)) :z (+ (* zr scale) (z pt)))))))) (defun cube-top-intersect (c pt xr yr zr) (unless (zerop yr) (multiple-value-bind (x-min x-max y-min y-max z-min z-max) (cube-bounds c pt) (let ((scale (/ y-max yr))) (if (and (<= x-min (* xr scale) x-max) (<= z-min (* zr scale) z-max)) (make-point :x (+ (* xr scale) (x pt)) :y (+ y-max (y pt)) :z (+ (* zr scale) (z pt)))))))) (defun cube-front-intersect (c pt xr yr zr) (unless (zerop zr) (multiple-value-bind (x-min x-max y-min y-max z-min z-max) (cube-bounds c pt) (let ((scale (/ z-min zr))) (if (and (<= x-min (* xr scale) x-max) (<= y-min (* yr scale) y-max)) (make-point :x (+ (* xr scale) (x pt)) :y (+ (* yr scale) (y pt)) :z (+ z-min (z pt)))))))) (defun cube-back-intersect (c pt xr yr zr) (unless (zerop zr) (multiple-value-bind (x-min x-max y-min y-max z-min z-max) (cube-bounds c pt) (let ((scale (/ z-max zr))) (if (and (<= x-min (* xr scale) x-max) (<= y-min (* yr scale) y-max)) (make-point :x (+ (* xr scale) (x pt)) :y (+ (* yr scale) (y pt)) :z (+ z-max (z pt)))))))) (defun closest-to (pt points) (let ((min (first points))) (dolist (point (rest points) min) (if (< (distance point pt) (distance min pt)) (setf min point))))) (defun cube-edge-point-p (c pt origin) (multiple-value-bind (x-min x-max y-min y-max z-min z-max) (cube-bounds c origin) (let ((x (x pt)) (y (y pt)) (z (z pt))) (or (and (= x x-min) (= y y-min)) (and (= x x-min) (= y y-max)) (and (= x x-min) (= z z-min)) (and (= x x-min) (= z z-max)) (and (= x x-max) (= y y-min)) (and (= x x-max) (= y y-max)) (and (= x x-max) (= z z-min)) (and (= x x-max) (= z z-max)) (and (= y y-min) (= z z-min)) (and (= y y-min) (= z z-max)) (and (= y y-max) (= z z-min)) (and (= y y-max) (= z z-min))))))
7,561
Common Lisp
.l
204
31.789216
101
0.513665
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c6be12810b0dc99c8185abc9170f27bc1149bddec18c8b781c9f5c74f7f8e26e
37,914
[ -1 ]
37,915
ray-tracing.lib
giorgianb_lray-tracer/ray-tracing.lib
#0Y_ #0Y |CHARSET|::|UTF-8| (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|SQ| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|X|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|MAG| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|X| |COMMON-LISP-USER|::|Y| |COMMON-LISP-USER|::|Z|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|UNIT-VECTOR| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|X| |COMMON-LISP-USER|::|Y| |COMMON-LISP-USER|::|Z|))) (|COMMON-LISP|::|LET| |COMMON-LISP|::|NIL| (|COMMON-LISP|::|LET| ((#1=#:|G15662| (|COMMON-LISP|::|CONS| '|COMMON-LISP-USER|::|POINT| (|CLOS|::|CLASS-NAMES| (|COMMON-LISP|::|GET| '|COMMON-LISP|::|STRUCTURE-OBJECT| '|CLOS|::|CLOSCLASS|))))) (|SYSTEM|::|STRUCTURE-UNDEFINE-ACCESSORIES| '|COMMON-LISP-USER|::|POINT|) (|COMMON-LISP|::|REMPROP| '|COMMON-LISP-USER|::|POINT| '|SYSTEM|::|DEFSTRUCT-DESCRIPTION|) (|CLOS|::|DEFINE-STRUCTURE-CLASS| '|COMMON-LISP-USER|::|POINT| #1# '|COMMON-LISP-USER|::|MAKE-POINT| '|COMMON-LISP|::|NIL| '|COMMON-LISP-USER|::|COPY-POINT| '|COMMON-LISP-USER|::|POINT-P| (|COMMON-LISP|::|LIST| (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|X| :|INITARGS| '#2=(:|X|) :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #3='|CLOS|::|INHERITABLE-INITER| (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #4=(|SYSTEM|::|MAKE-CONSTANT-INITFUNCTION| |COMMON-LISP|::|NIL|)) #5='|CLOS|::|INHERITABLE-DOC| '(|COMMON-LISP|::|NIL|) #6='|CLOS|::|LOCATION| '1. #7='|CLOS|::|READONLY| '|COMMON-LISP|::|NIL|) (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|Y| :|INITARGS| '#8=(:|Y|) :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #3# (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #9=(|SYSTEM|::|MAKE-CONSTANT-INITFUNCTION| |COMMON-LISP|::|NIL|)) #5# '(|COMMON-LISP|::|NIL|) #6# '2. #7# '|COMMON-LISP|::|NIL|) (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|Z| :|INITARGS| '#10=(:|Z|) :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #3# (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #11=(|SYSTEM|::|MAKE-CONSTANT-INITFUNCTION| |COMMON-LISP|::|NIL|)) #5# '(|COMMON-LISP|::|NIL|) #6# '3. #7# '|COMMON-LISP|::|NIL|)) (|COMMON-LISP|::|LIST| (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-DIRECT-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-DIRECT-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|X| :|INITARGS| '#2# :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #12='|CLOS|::|INHERITABLE-INITER| (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #4#) #13='|CLOS|::|INHERITABLE-DOC| '(|COMMON-LISP|::|NIL|) :|READERS| '(|COMMON-LISP-USER|::|X|) :|WRITERS| '((|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|X|))) (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-DIRECT-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-DIRECT-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|Y| :|INITARGS| '#8# :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #12# (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #9#) #13# '(|COMMON-LISP|::|NIL|) :|READERS| '(|COMMON-LISP-USER|::|Y|) :|WRITERS| '((|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Y|))) (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-DIRECT-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-DIRECT-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|Z| :|INITARGS| '#10# :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #12# (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #11#) #13# '(|COMMON-LISP|::|NIL|) :|READERS| '(|COMMON-LISP-USER|::|Z|) :|WRITERS| '((|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Z|))))) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|MAKE-POINT| (|COMMON-LISP|::|&KEY| (#14=#:|X| |COMMON-LISP|::|NIL|) (#15=#:|Y| |COMMON-LISP|::|NIL|) (#16=#:|Z| |COMMON-LISP|::|NIL|)) (|COMMON-LISP|::|LET| ((|SYSTEM|::|OBJECT| (|SYSTEM|::|%MAKE-STRUCTURE| #1# 4.))) (|COMMON-LISP|::|SETF| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 1.) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| #14#)) (|COMMON-LISP|::|SETF| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 2.) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| #15#)) (|COMMON-LISP|::|SETF| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 3.) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| #16#)) |SYSTEM|::|OBJECT|))) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|POINT-P|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|POINT-P| (|SYSTEM|::|OBJECT|) (|SYSTEM|::|%STRUCTURE-TYPE-P| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|COPY-POINT|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|COPY-POINT| (|COMMON-LISP|::|STRUCTURE|) (|COMMON-LISP|::|COPY-STRUCTURE| |COMMON-LISP|::|STRUCTURE|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|X| (|COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|X|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|X| #17=(|SYSTEM|::|OBJECT|) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 1.))) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|X| #18='|SYSTEM|::|DEFSTRUCT-READER| '|COMMON-LISP-USER|::|POINT|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|Y| (|COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|Y|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|Y| #17# (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 2.))) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|Y| #18# '|COMMON-LISP-USER|::|POINT|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|Z| (|COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|Z|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|Z| #17# (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 3.))) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|Z| #18# '|COMMON-LISP-USER|::|POINT|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|X|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|X|))) (|COMMON-LISP|::|DEFUN| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|X|) #19=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|) (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 1. |SYSTEM|::|VALUE|)) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|X| #20='|SYSTEM|::|DEFSTRUCT-WRITER| '|COMMON-LISP-USER|::|POINT|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Y|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Y|))) (|COMMON-LISP|::|DEFUN| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Y|) #19# (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 2. |SYSTEM|::|VALUE|)) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|Y| #20# '|COMMON-LISP-USER|::|POINT|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Z|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Z|))) (|COMMON-LISP|::|DEFUN| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Z|) #19# (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 3. |SYSTEM|::|VALUE|)) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|Z| #20# '|COMMON-LISP-USER|::|POINT|) (|SYSTEM|::|%SET-DOCUMENTATION| '|COMMON-LISP-USER|::|POINT| '|COMMON-LISP|::|TYPE| |COMMON-LISP|::|NIL|) (|CLOS|::|DEFSTRUCT-REMOVE-PRINT-OBJECT-METHOD| '|COMMON-LISP-USER|::|POINT|) '|COMMON-LISP-USER|::|POINT|) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|MAKE-POINT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP|::|&KEY| (#:|X| |COMMON-LISP|::|NIL|) (#:|Y| |COMMON-LISP|::|NIL|) (#:|Z| |COMMON-LISP|::|NIL|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|POINT-P|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|POINT-P| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|POINT-P|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|POINT-P| (|SYSTEM|::|%STRUCTURE-TYPE-P| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|COPY-POINT|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|COPY-POINT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|COMMON-LISP|::|STRUCTURE|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|COPY-POINT|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|COPY-POINT| (|COMMON-LISP|::|COPY-STRUCTURE| |COMMON-LISP|::|STRUCTURE|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|X| (|COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|X|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|X| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|X|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|X| (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 1.))))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|Y| (|COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|Y|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|Y| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|Y|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|Y| (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 2.))))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|Z| (|COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|Z|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|Z| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|Z|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|Z| (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 3.))))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|X|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|X|))) (|SYSTEM|::|C-DEFUN| '#1=(|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|X|) (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#2=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|)) '(#2# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| #1#)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|X| (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 1. |SYSTEM|::|VALUE|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Y|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Y|))) (|SYSTEM|::|C-DEFUN| '#1=(|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Y|) (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#2=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|)) '(#2# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| #1#)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|Y| (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 2. |SYSTEM|::|VALUE|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Z|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|POINT|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Z|))) (|SYSTEM|::|C-DEFUN| '#1=(|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|Z|) (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#2=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|)) '(#2# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| #1#)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|Z| (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|POINT| |SYSTEM|::|OBJECT| 3. |SYSTEM|::|VALUE|)))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|DISTANCE| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|P1| |COMMON-LISP-USER|::|P2|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|MINROOT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|A| |COMMON-LISP-USER|::|B| |COMMON-LISP-USER|::|C|))) (|COMMON-LISP|::|LET| |COMMON-LISP|::|NIL| (|COMMON-LISP|::|LET| ((#1=#:|G15739| (|COMMON-LISP|::|CONS| '|COMMON-LISP-USER|::|SURFACE| (|CLOS|::|CLASS-NAMES| (|COMMON-LISP|::|GET| '|COMMON-LISP|::|STRUCTURE-OBJECT| '|CLOS|::|CLOSCLASS|))))) (|SYSTEM|::|STRUCTURE-UNDEFINE-ACCESSORIES| '|COMMON-LISP-USER|::|SURFACE|) (|COMMON-LISP|::|REMPROP| '|COMMON-LISP-USER|::|SURFACE| '|SYSTEM|::|DEFSTRUCT-DESCRIPTION|) (|CLOS|::|DEFINE-STRUCTURE-CLASS| '|COMMON-LISP-USER|::|SURFACE| #1# '|COMMON-LISP-USER|::|MAKE-SURFACE| '|COMMON-LISP|::|NIL| '|COMMON-LISP-USER|::|COPY-SURFACE| '|COMMON-LISP-USER|::|SURFACE-P| (|COMMON-LISP|::|LIST| (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|COLOR| :|INITARGS| '#2=(:|COLOR|) :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| '|CLOS|::|INHERITABLE-INITER| (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #3=(|SYSTEM|::|MAKE-CONSTANT-INITFUNCTION| |COMMON-LISP|::|NIL|)) '|CLOS|::|INHERITABLE-DOC| '(|COMMON-LISP|::|NIL|) '|CLOS|::|LOCATION| '1. '|CLOS|::|READONLY| '|COMMON-LISP|::|NIL|)) (|COMMON-LISP|::|LIST| (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-DIRECT-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-DIRECT-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|COLOR| :|INITARGS| '#2# :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| '|CLOS|::|INHERITABLE-INITER| (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #3#) '|CLOS|::|INHERITABLE-DOC| '(|COMMON-LISP|::|NIL|) :|READERS| '(|COMMON-LISP-USER|::|SURFACE-COLOR|) :|WRITERS| '((|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SURFACE-COLOR|))))) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|MAKE-SURFACE| (|COMMON-LISP|::|&KEY| (#4=#:|COLOR| |COMMON-LISP|::|NIL|)) (|COMMON-LISP|::|LET| ((|SYSTEM|::|OBJECT| (|SYSTEM|::|%MAKE-STRUCTURE| #1# 2.))) (|COMMON-LISP|::|SETF| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SURFACE| |SYSTEM|::|OBJECT| 1.) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| #4#)) |SYSTEM|::|OBJECT|))) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SURFACE-P|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|SURFACE-P| (|SYSTEM|::|OBJECT|) (|SYSTEM|::|%STRUCTURE-TYPE-P| '|COMMON-LISP-USER|::|SURFACE| |SYSTEM|::|OBJECT|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|COPY-SURFACE|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|COPY-SURFACE| (|COMMON-LISP|::|STRUCTURE|) (|COMMON-LISP|::|COPY-STRUCTURE| |COMMON-LISP|::|STRUCTURE|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|SURFACE-COLOR| (|COMMON-LISP-USER|::|SURFACE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SURFACE-COLOR|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|SURFACE-COLOR| (|SYSTEM|::|OBJECT|) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SURFACE| |SYSTEM|::|OBJECT| 1.))) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|SURFACE-COLOR| '|SYSTEM|::|DEFSTRUCT-READER| '|COMMON-LISP-USER|::|SURFACE|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SURFACE-COLOR|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|SURFACE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SURFACE-COLOR|))) (|COMMON-LISP|::|DEFUN| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SURFACE-COLOR|) (|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|) (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|SURFACE| |SYSTEM|::|OBJECT| 1. |SYSTEM|::|VALUE|)) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|SURFACE-COLOR| '|SYSTEM|::|DEFSTRUCT-WRITER| '|COMMON-LISP-USER|::|SURFACE|) (|SYSTEM|::|%SET-DOCUMENTATION| '|COMMON-LISP-USER|::|SURFACE| '|COMMON-LISP|::|TYPE| |COMMON-LISP|::|NIL|) (|CLOS|::|DEFSTRUCT-REMOVE-PRINT-OBJECT-METHOD| '|COMMON-LISP-USER|::|SURFACE|) '|COMMON-LISP-USER|::|SURFACE|) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|MAKE-SURFACE| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP|::|&KEY| (#:|COLOR| |COMMON-LISP|::|NIL|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SURFACE-P|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|SURFACE-P| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|SURFACE-P|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|SURFACE-P| (|SYSTEM|::|%STRUCTURE-TYPE-P| '|COMMON-LISP-USER|::|SURFACE| |SYSTEM|::|OBJECT|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|COPY-SURFACE|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|COPY-SURFACE| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|COMMON-LISP|::|STRUCTURE|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|COPY-SURFACE|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|COPY-SURFACE| (|COMMON-LISP|::|COPY-STRUCTURE| |COMMON-LISP|::|STRUCTURE|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|SURFACE-COLOR| (|COMMON-LISP-USER|::|SURFACE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SURFACE-COLOR|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|SURFACE-COLOR| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|SURFACE-COLOR|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|SURFACE-COLOR| (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SURFACE| |SYSTEM|::|OBJECT| 1.))))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SURFACE-COLOR|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|SURFACE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SURFACE-COLOR|))) (|SYSTEM|::|C-DEFUN| '#1=(|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SURFACE-COLOR|) (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#2=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|)) '(#2# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| #1#)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|SURFACE-COLOR| (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|SURFACE| |SYSTEM|::|OBJECT| 1. |SYSTEM|::|VALUE|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|SPECIAL| |COMMON-LISP-USER|::|*WORLD*|)) (|SYSTEM|::|C-PROCLAIM-CONSTANT| '|COMMON-LISP-USER|::|EYE| '(|COMMON-LISP-USER|::|MAKE-POINT| :|X| 0. :|Y| 0. :|Z| 200.)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|TRACER| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP|::|PATHNAME| |COMMON-LISP|::|&OPTIONAL| (|COMMON-LISP-USER|::|RES| 1.)))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|COLOR-AT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|X| |COMMON-LISP-USER|::|Y|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|SENDRAY| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|FIRST-HIT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|LAMBERT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|S| |COMMON-LISP-USER|::|INT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|COMMON-LISP|::|LET| |COMMON-LISP|::|NIL| (|COMMON-LISP|::|LET| ((#1=#:|G15877| (|COMMON-LISP|::|CONS| '|COMMON-LISP-USER|::|SPHERE| (|CLOS|::|CLASS-NAMES| (|COMMON-LISP|::|GET| '|COMMON-LISP-USER|::|SURFACE| '|CLOS|::|CLOSCLASS|))))) (|SYSTEM|::|STRUCTURE-UNDEFINE-ACCESSORIES| '|COMMON-LISP-USER|::|SPHERE|) (|COMMON-LISP|::|REMPROP| '|COMMON-LISP-USER|::|SPHERE| '|SYSTEM|::|DEFSTRUCT-DESCRIPTION|) (|CLOS|::|DEFINE-STRUCTURE-CLASS| '|COMMON-LISP-USER|::|SPHERE| #1# '|COMMON-LISP-USER|::|MAKE-SPHERE| '|COMMON-LISP|::|NIL| '|COMMON-LISP-USER|::|COPY-SPHERE| '|COMMON-LISP-USER|::|SPHERE-P| (|COMMON-LISP|::|LIST| (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|COLOR| :|INITARGS| '(:|COLOR|) :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #2='|CLOS|::|INHERITABLE-INITER| (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| (|SYSTEM|::|FIND-STRUCTURE-CLASS-SLOT-INITFUNCTION| '|COMMON-LISP-USER|::|SURFACE| '|COMMON-LISP-USER|::|COLOR|)) #3='|CLOS|::|INHERITABLE-DOC| '(|COMMON-LISP|::|NIL|) #4='|CLOS|::|LOCATION| '1. #5='|CLOS|::|READONLY| '|COMMON-LISP|::|NIL|) (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|RADIUS| :|INITARGS| '#6=(:|RADIUS|) :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #2# (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #7=(|SYSTEM|::|MAKE-CONSTANT-INITFUNCTION| |COMMON-LISP|::|NIL|)) #3# '(|COMMON-LISP|::|NIL|) #4# '2. #5# '|COMMON-LISP|::|NIL|) (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|CENTER| :|INITARGS| '#8=(:|CENTER|) :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #2# (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #9=(|SYSTEM|::|MAKE-CONSTANT-INITFUNCTION| |COMMON-LISP|::|NIL|)) #3# '(|COMMON-LISP|::|NIL|) #4# '3. #5# '|COMMON-LISP|::|NIL|)) (|COMMON-LISP|::|LIST| (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-DIRECT-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-DIRECT-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|RADIUS| :|INITARGS| '#6# :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #10='|CLOS|::|INHERITABLE-INITER| (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #7#) #11='|CLOS|::|INHERITABLE-DOC| '(|COMMON-LISP|::|NIL|) :|READERS| '(|COMMON-LISP-USER|::|SPHERE-RADIUS|) :|WRITERS| '((|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-RADIUS|))) (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-DIRECT-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-DIRECT-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|CENTER| :|INITARGS| '#8# :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #10# (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #9#) #11# '(|COMMON-LISP|::|NIL|) :|READERS| '(|COMMON-LISP-USER|::|SPHERE-CENTER|) :|WRITERS| '((|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-CENTER|))))) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|MAKE-SPHERE| (|COMMON-LISP|::|&KEY| (#12=#:|COLOR| |COMMON-LISP|::|NIL|) (#13=#:|RADIUS| |COMMON-LISP|::|NIL|) (#14=#:|CENTER| |COMMON-LISP|::|NIL|)) (|COMMON-LISP|::|LET| ((|SYSTEM|::|OBJECT| (|SYSTEM|::|%MAKE-STRUCTURE| #1# 4.))) (|COMMON-LISP|::|SETF| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 1.) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| #12#)) (|COMMON-LISP|::|SETF| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 2.) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| #13#)) (|COMMON-LISP|::|SETF| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 3.) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| #14#)) |SYSTEM|::|OBJECT|))) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SPHERE-P|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|SPHERE-P| (|SYSTEM|::|OBJECT|) (|SYSTEM|::|%STRUCTURE-TYPE-P| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|COPY-SPHERE|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|COPY-SPHERE| (|COMMON-LISP|::|STRUCTURE|) (|COMMON-LISP|::|COPY-STRUCTURE| |COMMON-LISP|::|STRUCTURE|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|SPHERE-COLOR| (|COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SPHERE-COLOR|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|SPHERE-COLOR| #15=(|SYSTEM|::|OBJECT|) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 1.))) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|SPHERE-COLOR| #16='|SYSTEM|::|DEFSTRUCT-READER| '|COMMON-LISP-USER|::|SPHERE|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|SPHERE-RADIUS| (|COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SPHERE-RADIUS|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|SPHERE-RADIUS| #15# (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 2.))) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|SPHERE-RADIUS| #16# '|COMMON-LISP-USER|::|SPHERE|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|SPHERE-CENTER| (|COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SPHERE-CENTER|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|SPHERE-CENTER| #15# (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 3.))) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|SPHERE-CENTER| #16# '|COMMON-LISP-USER|::|SPHERE|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-COLOR|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-COLOR|))) (|COMMON-LISP|::|DEFUN| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-COLOR|) #17=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|) (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 1. |SYSTEM|::|VALUE|)) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|SPHERE-COLOR| #18='|SYSTEM|::|DEFSTRUCT-WRITER| '|COMMON-LISP-USER|::|SPHERE|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-RADIUS|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-RADIUS|))) (|COMMON-LISP|::|DEFUN| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-RADIUS|) #17# (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 2. |SYSTEM|::|VALUE|)) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|SPHERE-RADIUS| #18# '|COMMON-LISP-USER|::|SPHERE|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-CENTER|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-CENTER|))) (|COMMON-LISP|::|DEFUN| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-CENTER|) #17# (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 3. |SYSTEM|::|VALUE|)) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|SPHERE-CENTER| #18# '|COMMON-LISP-USER|::|SPHERE|) (|SYSTEM|::|%SET-DOCUMENTATION| '|COMMON-LISP-USER|::|SPHERE| '|COMMON-LISP|::|TYPE| |COMMON-LISP|::|NIL|) (|CLOS|::|DEFSTRUCT-REMOVE-PRINT-OBJECT-METHOD| '|COMMON-LISP-USER|::|SPHERE|) '|COMMON-LISP-USER|::|SPHERE|) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|MAKE-SPHERE| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP|::|&KEY| (#:|COLOR| |COMMON-LISP|::|NIL|) (#:|RADIUS| |COMMON-LISP|::|NIL|) (#:|CENTER| |COMMON-LISP|::|NIL|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SPHERE-P|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|SPHERE-P| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|SPHERE-P|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|SPHERE-P| (|SYSTEM|::|%STRUCTURE-TYPE-P| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|COPY-SPHERE|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|COPY-SPHERE| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|COMMON-LISP|::|STRUCTURE|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|COPY-SPHERE|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|COPY-SPHERE| (|COMMON-LISP|::|COPY-STRUCTURE| |COMMON-LISP|::|STRUCTURE|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|SPHERE-COLOR| (|COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SPHERE-COLOR|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|SPHERE-COLOR| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|SPHERE-COLOR|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|SPHERE-COLOR| (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 1.))))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|SPHERE-RADIUS| (|COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SPHERE-RADIUS|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|SPHERE-RADIUS| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|SPHERE-RADIUS|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|SPHERE-RADIUS| (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 2.))))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|SPHERE-CENTER| (|COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|SPHERE-CENTER|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|SPHERE-CENTER| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|SPHERE-CENTER|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|SPHERE-CENTER| (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 3.))))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-COLOR|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-COLOR|))) (|SYSTEM|::|C-DEFUN| '#1=(|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-COLOR|) (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#2=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|)) '(#2# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| #1#)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|SPHERE-COLOR| (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 1. |SYSTEM|::|VALUE|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-RADIUS|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-RADIUS|))) (|SYSTEM|::|C-DEFUN| '#1=(|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-RADIUS|) (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#2=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|)) '(#2# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| #1#)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|SPHERE-RADIUS| (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 2. |SYSTEM|::|VALUE|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-CENTER|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|SPHERE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-CENTER|))) (|SYSTEM|::|C-DEFUN| '#1=(|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|SPHERE-CENTER|) (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#2=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|)) '(#2# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| #1#)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|SPHERE-CENTER| (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|SPHERE| |SYSTEM|::|OBJECT| 3. |SYSTEM|::|VALUE|)))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|DEFSPHERE| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|X| |COMMON-LISP-USER|::|Y| |COMMON-LISP-USER|::|Z| |COMMON-LISP-USER|::|R| |COMMON-LISP-USER|::|C|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|INTERSECT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|S| |COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|SPHERE-INTERSECT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|S| |COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|NORMAL| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|S| |COMMON-LISP-USER|::|PT|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|SPHERE-NORMAL| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|S| |COMMON-LISP-USER|::|PT|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|RAY-TEST| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP|::|&OPTIONAL| (|COMMON-LISP-USER|::|RES| 1.)))) (|COMMON-LISP|::|LET| |COMMON-LISP|::|NIL| (|COMMON-LISP|::|LET| ((#1=#:|G16053| (|COMMON-LISP|::|CONS| '|COMMON-LISP-USER|::|CUBE| (|CLOS|::|CLASS-NAMES| (|COMMON-LISP|::|GET| '|COMMON-LISP-USER|::|SURFACE| '|CLOS|::|CLOSCLASS|))))) (|SYSTEM|::|STRUCTURE-UNDEFINE-ACCESSORIES| '|COMMON-LISP-USER|::|CUBE|) (|COMMON-LISP|::|REMPROP| '|COMMON-LISP-USER|::|CUBE| '|SYSTEM|::|DEFSTRUCT-DESCRIPTION|) (|CLOS|::|DEFINE-STRUCTURE-CLASS| '|COMMON-LISP-USER|::|CUBE| #1# '|COMMON-LISP-USER|::|MAKE-CUBE| '|COMMON-LISP|::|NIL| '|COMMON-LISP-USER|::|COPY-CUBE| '|COMMON-LISP-USER|::|CUBE-P| (|COMMON-LISP|::|LIST| (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|COLOR| :|INITARGS| '(:|COLOR|) :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #2='|CLOS|::|INHERITABLE-INITER| (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| (|SYSTEM|::|FIND-STRUCTURE-CLASS-SLOT-INITFUNCTION| '|COMMON-LISP-USER|::|SURFACE| '|COMMON-LISP-USER|::|COLOR|)) #3='|CLOS|::|INHERITABLE-DOC| '(|COMMON-LISP|::|NIL|) #4='|CLOS|::|LOCATION| '1. #5='|CLOS|::|READONLY| '|COMMON-LISP|::|NIL|) (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|SIDE-LENGTH| :|INITARGS| '#6=(:|SIDE-LENGTH|) :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #2# (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #7=(|SYSTEM|::|MAKE-CONSTANT-INITFUNCTION| |COMMON-LISP|::|NIL|)) #3# '(|COMMON-LISP|::|NIL|) #4# '2. #5# '|COMMON-LISP|::|NIL|) (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-EFFECTIVE-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|CENTER| :|INITARGS| '#8=(:|CENTER|) :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #2# (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #9=(|SYSTEM|::|MAKE-CONSTANT-INITFUNCTION| |COMMON-LISP|::|NIL|)) #3# '(|COMMON-LISP|::|NIL|) #4# '3. #5# '|COMMON-LISP|::|NIL|)) (|COMMON-LISP|::|LIST| (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-DIRECT-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-DIRECT-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|SIDE-LENGTH| :|INITARGS| '#6# :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #10='|CLOS|::|INHERITABLE-INITER| (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #7#) #11='|CLOS|::|INHERITABLE-DOC| '(|COMMON-LISP|::|NIL|) :|READERS| '(|COMMON-LISP-USER|::|CUBE-SIDE-LENGTH|) :|WRITERS| '((|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH|))) (|CLOS|::|MAKE-INSTANCE-<STRUCTURE-DIRECT-SLOT-DEFINITION>| |CLOS|::|<STRUCTURE-DIRECT-SLOT-DEFINITION>| :|NAME| '|COMMON-LISP-USER|::|CENTER| :|INITARGS| '#8# :|TYPE| '|COMMON-LISP|::|T| :|ALLOCATION| ':|INSTANCE| #10# (|CLOS|::|MAKE-INHERITABLE-SLOT-DEFINITION-INITER| '|COMMON-LISP|::|NIL| #9#) #11# '(|COMMON-LISP|::|NIL|) :|READERS| '(|COMMON-LISP-USER|::|CUBE-CENTER|) :|WRITERS| '((|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-CENTER|))))) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|MAKE-CUBE| (|COMMON-LISP|::|&KEY| (#12=#:|COLOR| |COMMON-LISP|::|NIL|) (#13=#:|SIDE-LENGTH| |COMMON-LISP|::|NIL|) (#14=#:|CENTER| |COMMON-LISP|::|NIL|)) (|COMMON-LISP|::|LET| ((|SYSTEM|::|OBJECT| (|SYSTEM|::|%MAKE-STRUCTURE| #1# 4.))) (|COMMON-LISP|::|SETF| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 1.) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| #12#)) (|COMMON-LISP|::|SETF| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 2.) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| #13#)) (|COMMON-LISP|::|SETF| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 3.) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| #14#)) |SYSTEM|::|OBJECT|))) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|CUBE-P|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|CUBE-P| (|SYSTEM|::|OBJECT|) (|SYSTEM|::|%STRUCTURE-TYPE-P| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|COPY-CUBE|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|COPY-CUBE| (|COMMON-LISP|::|STRUCTURE|) (|COMMON-LISP|::|COPY-STRUCTURE| |COMMON-LISP|::|STRUCTURE|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|CUBE-COLOR| (|COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|CUBE-COLOR|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|CUBE-COLOR| #15=(|SYSTEM|::|OBJECT|) (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 1.))) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|CUBE-COLOR| #16='|SYSTEM|::|DEFSTRUCT-READER| '|COMMON-LISP-USER|::|CUBE|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH| (|COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH| #15# (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 2.))) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|CUBE-SIDE-LENGTH| #16# '|COMMON-LISP-USER|::|CUBE|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|CUBE-CENTER| (|COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|CUBE-CENTER|)) (|COMMON-LISP|::|DEFUN| |COMMON-LISP-USER|::|CUBE-CENTER| #15# (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 3.))) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|CUBE-CENTER| #16# '|COMMON-LISP-USER|::|CUBE|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-COLOR|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-COLOR|))) (|COMMON-LISP|::|DEFUN| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-COLOR|) #17=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|) (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 1. |SYSTEM|::|VALUE|)) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|CUBE-COLOR| #18='|SYSTEM|::|DEFSTRUCT-WRITER| '|COMMON-LISP-USER|::|CUBE|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH|))) (|COMMON-LISP|::|DEFUN| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH|) #17# (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 2. |SYSTEM|::|VALUE|)) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|CUBE-SIDE-LENGTH| #18# '|COMMON-LISP-USER|::|CUBE|) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-CENTER|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|COMMON-LISP|::|PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-CENTER|))) (|COMMON-LISP|::|DEFUN| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-CENTER|) #17# (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 3. |SYSTEM|::|VALUE|)) (|SYSTEM|::|%PUT| '|COMMON-LISP-USER|::|CUBE-CENTER| #18# '|COMMON-LISP-USER|::|CUBE|) (|SYSTEM|::|%SET-DOCUMENTATION| '|COMMON-LISP-USER|::|CUBE| '|COMMON-LISP|::|TYPE| |COMMON-LISP|::|NIL|) (|CLOS|::|DEFSTRUCT-REMOVE-PRINT-OBJECT-METHOD| '|COMMON-LISP-USER|::|CUBE|) '|COMMON-LISP-USER|::|CUBE|) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|MAKE-CUBE| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP|::|&KEY| (#:|COLOR| |COMMON-LISP|::|NIL|) (#:|SIDE-LENGTH| |COMMON-LISP|::|NIL|) (#:|CENTER| |COMMON-LISP|::|NIL|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|CUBE-P|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-P| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|CUBE-P|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|CUBE-P| (|SYSTEM|::|%STRUCTURE-TYPE-P| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|COPY-CUBE|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|COPY-CUBE| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|COMMON-LISP|::|STRUCTURE|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|COPY-CUBE|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|COPY-CUBE| (|COMMON-LISP|::|COPY-STRUCTURE| |COMMON-LISP|::|STRUCTURE|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|CUBE-COLOR| (|COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|CUBE-COLOR|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-COLOR| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|CUBE-COLOR|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|CUBE-COLOR| (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 1.))))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH| (|COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-SIDE-LENGTH| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH| (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 2.))))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| |COMMON-LISP-USER|::|CUBE-CENTER| (|COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| |COMMON-LISP-USER|::|CUBE-CENTER|)) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-CENTER| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#1=(|SYSTEM|::|OBJECT|)) '(#1# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| |COMMON-LISP-USER|::|CUBE-CENTER|)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|CUBE-CENTER| (|COMMON-LISP|::|THE| |COMMON-LISP|::|T| (|SYSTEM|::|%STRUCTURE-REF| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 3.))))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-COLOR|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-COLOR|))) (|SYSTEM|::|C-DEFUN| '#1=(|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-COLOR|) (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#2=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|)) '(#2# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| #1#)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|CUBE-COLOR| (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 1. |SYSTEM|::|VALUE|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH|))) (|SYSTEM|::|C-DEFUN| '#1=(|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH|) (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#2=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|)) '(#2# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| #1#)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|CUBE-SIDE-LENGTH| (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 2. |SYSTEM|::|VALUE|)))) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|FUNCTION| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-CENTER|) (|COMMON-LISP|::|T| |COMMON-LISP-USER|::|CUBE|) |COMMON-LISP|::|T|)) (|SYSTEM|::|C-PROCLAIM| '(|COMMON-LISP|::|INLINE| (|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-CENTER|))) (|SYSTEM|::|C-DEFUN| '#1=(|COMMON-LISP|::|SETF| |COMMON-LISP-USER|::|CUBE-CENTER|) (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '#2=(|SYSTEM|::|VALUE| |SYSTEM|::|OBJECT|)) '(#2# (|COMMON-LISP|::|DECLARE| (|SYSTEM|::|IN-DEFUN| #1#)) (|COMMON-LISP|::|BLOCK| |COMMON-LISP-USER|::|CUBE-CENTER| (|SYSTEM|::|%STRUCTURE-STORE| '|COMMON-LISP-USER|::|CUBE| |SYSTEM|::|OBJECT| 3. |SYSTEM|::|VALUE|)))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|DEFCUBE| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|X| |COMMON-LISP-USER|::|Y| |COMMON-LISP-USER|::|Z| |COMMON-LISP-USER|::|S| |COMMON-LISP-USER|::|C|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-INTERSECT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|C| |COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-NORMAL| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|CUBE| |COMMON-LISP-USER|::|PT|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-BOUNDS| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|CUBE| |COMMON-LISP|::|&OPTIONAL| (|COMMON-LISP-USER|::|ORIGIN| (|COMMON-LISP-USER|::|MAKE-POINT| :|X| 0. :|Y| 0. :|Z| 0.))))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-LEFT-INTERSECT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|C| |COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-RIGHT-INTERSECT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|C| |COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-BOTTOM-INTERSECT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|C| |COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-TOP-INTERSECT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|C| |COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-FRONT-INTERSECT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|C| |COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-BACK-INTERSECT| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|C| |COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|XR| |COMMON-LISP-USER|::|YR| |COMMON-LISP-USER|::|ZR|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CLOSEST-TO| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|POINTS|))) (|SYSTEM|::|C-DEFUN| '|COMMON-LISP-USER|::|CUBE-EDGE-POINT-P| (|SYSTEM|::|LAMBDA-LIST-TO-SIGNATURE| '(|COMMON-LISP-USER|::|C| |COMMON-LISP-USER|::|PT| |COMMON-LISP-USER|::|ORIGIN|)))
52,847
Common Lisp
.l
1,036
47.396718
79
0.608635
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
58a0a68b5542b0c33e50b48c7656d116f112cf700c5855f287501867345475ee
37,915
[ -1 ]
37,916
surface.l
giorgianb_lray-tracer/surface.l
(defpackage "SURFACE" (:use "COMMON-LISP") (:export "SURFACE" "WITH-SURFACE")) (defstruct surface color) (defmacro with-surface (vars p &body body) (if (/= (length vars) 1) (error "Variable specification must specify 1 variables.")) (let ((p-sym (gensym))) `(let* ((,p-sym ,p) (,(first vars) (surface-color ,p-sym))) ,@body)))
361
Common Lisp
.l
12
26.25
65
0.62536
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cbda95e0f2903f84be82e34cd4652879c2de04f0d2ff50d358c6e40ed0e8a9bd
37,916
[ -1 ]
37,917
3d-images.l
giorgianb_lray-tracer/3d-images.l
(defpackage "3D-IMAGES" (:use "COMMON-LISP" "3D") (:export "SURFACE" "SURFACE-COLOR" "SPHERE-IMAGE" "PLANE-IMAGE" "DEFOBJECT" "DEFSPHERE" "DEFPLANE")) (in-package 3d-images) (defclass surface () ((color :type integer :reader surface-color :initarg :color))) (defclass sphere-image (sphere surface) ()) (defclass plane-image (plane surface) ()) (defmacro defobject (obj world) `(push ,obj ,world)) (defmacro defsphere (x y z r c w) (let ((s-sym (gensym))) `(let ((,s-sym (make-instance 'sphere-image :center (make-instance '3d-point :x ,x :y ,y :z ,z) :radius ,r :color ,c))) (push ,s-sym ,w)))) (defmacro defplane (x1 y1 z1 x2 y2 z2 x3 y3 z3 c w) (let ((p-sym (gensym))) `(let ((,p-sym (make-instance 'plane-image :p1 (make-instance '3d-point :x ,x1 :y ,y1 :z ,z1) :p2 (make-instance '3d-point :x ,x2 :y ,y2 :z ,z2) :p3 (make-instance '3d-point :x ,x3 :y ,y3 :z ,z3) :color ,c))) (push ,p-sym ,w))))
1,116
Common Lisp
.l
40
21.5
77
0.547329
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
40bcf63ba3bac0ef2bbc7c6635aee032b65bd7be91fb9d1aa150e39eb727a817
37,917
[ -1 ]
37,918
ray-test.l
giorgianb_lray-tracer/ray-test.l
(defpackage "RAY-TEST" (:use "COMMON-LISP" "RAY-TRACER" "3D-IMAGES" "3D") (:export "RAY-TEST")) (in-package ray-test) (defun ray-test (&optional (res 1)) (declare (integer res)) (let (world (eye (make-instance '3d-point :x 0 :y 0 :z 200))) (defsphere 0 -300 -1200 200 .8 world) (defsphere -80 -150 -1200 200 .7 world) (defsphere 70 -100 -1200 200 .9 world) (defplane -400 300 -600 -400 300 -1200 -200 300 -600 .9 world) (do ((x -2 (1+ x))) ((> x 2)) (do ((z 2 (1+ z))) ((> z 7)) (defsphere (* x 200) 300 (* z -300) 40 .75 world))) (tracer world eye (make-pathname :name "test.pgm") res)))
675
Common Lisp
.l
24
23.541667
61
0.561728
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
20447c6f14e8239cc4eff9fa5da4d73b72e518da70bc4c65741278e957452db7
37,918
[ -1 ]
37,919
image-plane.l
giorgianb_lray-tracer/image-plane.l
(defpackage "IMAGE-PLANE" (:use "COMMON-LISP" "PLANE" "SURFACE") (:export "IMAGE-PLANE" "WITH-IMAGE-PLANE")) (defstruct (image-plane-base (:include plane))) (defstruct (image-plane (:include surface))) (defmacro with-image-plane (vars p &body body) (if (/= (length vars) 4) (error "Variable specification must specify 4 variables.")) (let ((p-sym (gensym))) `(let* ((,p-sym ,p) (,(first vars) (plane-p1 ,p-sym)) (,(second vars) (plane-p2 ,p-sym)) (,(third vars) (plane-p3 ,p-sym)) (,(fourth vars) (surface-color ,p-sym))) ,@body)))
579
Common Lisp
.l
15
34.466667
65
0.622776
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d35ba51e82706187371295113cf2e323fe823411990b89ec95ea3e36062bc1b6
37,919
[ -1 ]
37,920
3d-point.l
giorgianb_lray-tracer/3d-point.l
(defpackage "3D-POINT" (:use "COMMON-LISP") (:export "3D-POINT" "3D-POINT-X" "3D-POINT-Y" "3D-POINT-Z" "WITH-3D-POINT" "POINT-DISTANCE")) (in-package 3d-point)
170
Common Lisp
.l
5
31
60
0.656442
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a403f2ead87d58499cb80bac474fde1ab63b1b65cc1e96e68f37632c82b51c71
37,920
[ -1 ]
37,921
sphere.l
giorgianb_lray-tracer/sphere.l
(defpackage "SPHERE" (:use "COMMON-LISP" "3D-VECTOR" "3D-POINT") (:export "SPHERE" "WITH-SPHERE" "SPHERE-INTERSECT" "SPHERE-NORMAL")) (defun sphere-intersect (s vp v) (defun sphere-normal (s pt) (defun on-sphere (s pt)
241
Common Lisp
.l
6
35.5
70
0.705069
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a364161f162085d870600d336da1d5bf5d6c7ea3ba113d6cc357b842f77efbb0
37,921
[ -1 ]
37,922
image-sphere.l
giorgianb_lray-tracer/image-sphere.l
(defpackage "IMAGE-SPHERE" (:use "COMMON-LISP" "SPHERE") (:export "IMAGE-SPHERE")) (defstruct image-sphere (defstruct image-sphere (image-sphere (:include plane surface))) (defmacro with-image-sphere (vars p &body body) (if (/= (length vars) 3) (error "Variable specification must specify 3 variables!")) (let ((p-sym (geyns-sym))) `(let* ((,p-sym ,p) (,(first vars) (sphere-center ,p-sym)) (,(second vars) (sphere-radius ,p-sym)) (,(third vars) (surface-color ,p-sym))) ,@body)))
523
Common Lisp
.l
14
33.357143
65
0.642998
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7ab63c88038345de18477994bc73f6c1938ed74d279e6148e57f5b2b10b647cf
37,922
[ -1 ]
37,923
ray-tracer.l
giorgianb_lray-tracer/ray-tracer.l
(defpackage "RAY-TRACER" (:use "COMMON-LISP" "3D-IMAGES" "3D") (:export "TRACER")) (in-package ray-tracer) (defun tracer (world eye pathname &optional (res 1)) (declare (list world) (3d-point eye) (integer res)) (with-open-file (p pathname :direction :output :if-exists :supersede) (format p "P2 ~A ~A 255" (* res 100) (* res 100)) (let ((inc (/ res))) (do ((y -50 (+ y inc))) ((< (- 50 y) inc)) (do ((x -50 (+ x inc))) ((< (- 50 x) inc)) (print (color-at world eye x y) p)))))) (defun color-at (world eye x y) (declare (list world) (3d-point eye) (number x y)) (with-3d-point (ex ey ez) eye (round (* (send-ray world eye (unit-vector (make-instance '3d-vector :x (- x ex) :y (- y ey) :z (- ez)))) 256)))) (defun send-ray (world pt v) (declare (list world) (3d-point pt) (3d-vector v)) (multiple-value-bind (s hit) (first-hit world pt v) (if s (* (light-intensity s hit v) (surface-color s)) 0))) (defun first-hit (world pt v) (declare (list world) (3d-point pt) (3d-vector v)) (let (surface hit dist) (dolist (o world) (let ((h (intersect o pt v))) (when h (let ((d (distance h pt))) (when (or (null dist) (< d dist)) (setf surface o hit h dist d)))))) (values surface hit))) (defun light-intensity (o pt v) (declare (3d-point pt) (3d-vector v)) (max 0 (dot-product (normal o pt) v)))
1,429
Common Lisp
.l
41
30.365854
72
0.582187
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
73cc0b06daaff58bf187607ec116ecaa117dfd74be5d62d1710cb12dd2495b36
37,923
[ -1 ]
37,924
planer-object.l
giorgianb_lray-tracer/planer-object.l
(defstruct planer-object planes) (defun vector-cross-product (x1r y1r z1r x2r y2r z2r) (values (- (* y1r z2r) (* z1r y2r)) (- (* z1r x2r) (* x1r z2r)) (- (* x1r y2r) (* y1r x2r)))) (defun plane-normal-vector (p) ( (defun plane-intersect (p pt xr yr zr) (multiple-value-bind (xn yn zn) (vector-cross-product
328
Common Lisp
.l
10
29.7
55
0.649518
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e20b2889cbd514608a79aac37185cc447300179167331bf8a032ac2b09119f06
37,924
[ -1 ]
37,925
point.l
giorgianb_lray-tracer/rt/point.l
(defpackage "RT-POINT" (:use "COMMON-LISP") (:export "POINT" "MAKE" "NTH-COMPONENT" "DIMENSIONS" "WITH" "*ORIGIN*" "EQUIV")) (in-package rt-point) (defclass point () ((components :type array :reader components :initarg :components))) (defun make (points) (declare (list points)) (make-instance 'point :components (make-array (length points) :initial-contents points :element-type 'real))) (defun nth-component (p n) (declare (point p) (integer n)) (if (and (< n (length (components p))) (>= n 0)) (aref (components p) n) 0.0d0)) (defmacro dimensions (p) `(length (components ,p))) (defmacro with (p vars &body body) (declare (list vars body)) (let* ((p-sym (gensym)) (n 0) (var-spec (mapcar #'(lambda (var) (incf n) `(,var (nth-component ,p-sym ,(1- n)))) vars))) `(let* ((,p-sym ,p) ,@var-spec) (declare (point p)) ,@(mapcar #'(lambda (var) `(declare (real ,var))) vars) ,@body))) (defun equiv (p1 p2) (let* ((pc1 (components p1)) (pc2 (components p2)) (len1 (length pc1)) (len2 (length pc2)) (len (min len1 len2)) (equal t)) (do ((i 0 (1+ i))) ((or (not equal) (>= i len)) equal) (setf equal (= (aref pc1 i) (aref pc2 i)))))) (defparameter *origin* (make '()))
1,321
Common Lisp
.l
47
23.744681
90
0.58903
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
020ab3f1e65078facab584842042cb0b8e7fa13dc632b1d967e2e340f9af3771
37,925
[ -1 ]
37,926
vector.l
giorgianb_lray-tracer/rt/vector.l
;(defpackage "RT-VEC" ; (:use "COMMON-LISP") ; (:require "RT-POINT") ; (:export "VEC" ; "MAKE-VEC" ; "VEC-NTH-COMPONENT" ; "VEC-DIMENSIONS" ; "WITH-VEC")) ;(in-package rt-vec) (defclass vec () ((point-1 :type rt-point:point :reader point-1 :initarg :point-1) (point-2 :type rt-point:point :reader point-2 :initarg :point-2))) (defun make (p1 p2) (declare (rt-point:point p1) (rt-point:point p2)) (make-instance 'vec :point-1 p1 :point-2 p2)) (defun nth-component (v n) (declare (vec v) (integer n)) (- (rt-point:nth-component (point-2 v) n) (rt-point:nth-component (point-1 v) n))) (defun dimensions (v) (max (rt-point:dimensions (point-1 v)) (rt-point:dimensions (point-2 v)))) (defun magnitude (v) (declare (vec v)) (let ((d (dimensions v))) (flet ((squared-diff (i) (expt (- (rt-point:nth-component (point-1 v) i) (rt-point:nth-component (point-2 v) i)) 2))) (do* ((i 0 (1+ i)) (m (squared-diff i) (+ m (squared-diff i)))) ((>= i d) (sqrt m)))))) (defun add (v1 v2 &optional center) (declare (vec v1) (vec v2))
1,114
Common Lisp
.l
34
29.264706
76
0.609595
giorgianb/lray-tracer
0
0
0
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5e45d0749db27aad0aae1d5b7ccdd2853161531deb73f69d9c1b9f4f09e34ce9
37,926
[ -1 ]
37,941
minesweeper.lisp
phua_lisp-games/minesweeper.lisp
;;; minesweeper.lisp --- Minesweeper ;; Author: Peter Hua ;; Version: $Revision: 1.0$ ;; Keywords: $keywords ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: ;; (minesweeper-cli) ;; (minesweeper-server) ;; (minesweeper-ncurses) ;;; Code: (ql:quickload '("portable-threads" "usocket")) (load "~/quicklisp/dists/quicklisp/software/usocket-0.7.1/server.lisp") (in-package #:common-lisp-user) (defpackage #:lisp.games.minesweeper (:use #:common-lisp #:portable-threads #:usocket) (:export #:minesweeper-cli #:minesweeper-server)) (in-package #:lisp.games.minesweeper) (defstruct cell "A minefield cell." (mine-count 0 :type integer) (mine-p nil :type boolean) (flag-p nil :type boolean) (visible-p nil :type boolean) (neighbors nil :type list)) (let ((neighborhood '((-1 -1) (-1 0) (-1 1) (0 -1) (0 1) (1 -1) (1 0) (1 1)))) (defun get-neighbors (row column minefield) "Get neighbors at (`row', `column'). => a list of subscripts." (remove-if-not #'(lambda (neighbor) (array-in-bounds-p minefield (car neighbor) (cadr neighbor))) (mapcar #'(lambda (neighbor) (mapcar #'+ (list row column) neighbor)) neighborhood)))) (let ((min-dimensions '(3 3)) (max-dimensions '(30 24)) (max-mine-count 0.92638)) (defun make-minefield (&optional (dimensions '(30 24)) (mine-count 667)) "Make minefield and set mines. => `minefield'." (let* ((dimensions (mapcar #'min (mapcar #'max dimensions min-dimensions) max-dimensions)) (mine-count (min mine-count (floor (* (apply #'* dimensions) max-mine-count)))) (minefield (make-array dimensions :element-type 'cell)) (size (array-total-size minefield))) (dotimes (row (car dimensions)) (dotimes (column (cadr dimensions)) (setf (aref minefield row column) (make-cell)) (setf (cell-neighbors (aref minefield row column)) (get-neighbors row column minefield)))) (do ((index (random size) (random size))) ((<= mine-count 0) minefield) (let ((cell (row-major-aref minefield index))) (unless (cell-mine-p cell) (setf (cell-mine-p cell) t) (dolist (neighbor (cell-neighbors cell)) (incf (cell-mine-count (aref minefield (car neighbor) (cadr neighbor))))) (setf mine-count (1- mine-count)))))))) ;; Commands (defmacro with-cell (row column minefield &body body) "Anaphoric macro that performs array bounds checking and binds symbol `cell'." `(when (array-in-bounds-p ,minefield ,row ,column) (let ((cell (aref ,minefield ,row ,column))) ,@body))) (defun clear-minefield (row column minefield &optional (results nil)) "Clear minefield recursively. => `results', a list of subscripts modified and their values." (with-cell row column minefield (unless (cell-visible-p cell) (setf (cell-visible-p cell) t) (push (list row column (cell-value cell)) results) (unless (or (/= (cell-mine-count cell) 0) (cell-flag-p cell) (cell-mine-p cell)) (dolist (neighbor (cell-neighbors cell) results) (setf results (clear-minefield (car neighbor) (cadr neighbor) minefield results)))))) results) (defun toggle-flag (row column minefield) "Toggle flag at (`row', `column'). => a list of subscripts modified and their values." (with-cell row column minefield (setf (cell-flag-p cell) (not (cell-flag-p cell))) (list (list row column (cell-value cell))))) (defun reset-minefield (minefield) "Reset minefield and unset flags. => `minefield'." (dotimes (index (array-total-size minefield) minefield) (let ((cell (row-major-aref minefield index))) (setf (cell-flag-p cell) nil) (setf (cell-visible-p cell) nil)))) (defun end-game-p (command row column minefield) "Check for end of game. A game is won iff all mines are correctly flagged. => `WIN' or `LOSE' if end of game; otherwise, `nil'." (with-cell row column minefield (if (and (eq command 'clear) (cell-mine-p cell)) 'LOSE (dotimes (index (array-total-size minefield) 'WIN) (let ((cell (row-major-aref minefield index))) (unless (eq (cell-mine-p cell) (cell-flag-p cell)) (return-from end-game-p nil))))))) (defun reveal-minefield (minefield) "Reveal minefield. => `minefield'." (dotimes (index (array-total-size minefield) minefield) (setf (cell-visible-p (row-major-aref minefield index)) t))) (defun save-minefield (minefield filename) "Save minefield to filename." (with-open-file (stream filename :direction :output :if-exists :supersede) (princ minefield stream))) (defun load-minefield (filename) "Load minefield from filename. => `minefield'." (with-open-file (stream filename :direction :input :if-does-not-exist :error) (read stream))) ;; Command Line Interface (defun cell-value (cell) "Convert cell to a printable value." (cond ((cell-flag-p cell) #\?) ((not (cell-visible-p cell)) #\.) ((cell-mine-p cell) #\!) ((> (cell-mine-count cell) 0) (cell-mine-count cell)) (t #\SPACE))) (defun print-minefield (minefield &optional (stream t)) "Print minefield to stream." (let* ((dimensions (array-dimensions minefield)) (rows (first dimensions)) (columns (second dimensions))) (flet ((print-columns () (format stream " ") (dotimes (c columns) (format stream "~4D" c))) (print-separator () (print-newline :stream stream) (format stream " +") (loop repeat columns do (format stream "---+")) (print-newline :stream stream))) (print-columns) (print-separator) (dotimes (r rows) (format stream "~3D |" r) (dotimes (c columns) (format stream " ~A |" (cell-value (aref minefield r c)))) (print-separator)) (print-columns)))) (defun print-commands (&optional (stream t)) "Print commands to stream." (format stream "~ COMMANDS clear ROW COLUMN Clear cell at ROW COLUMN. flag ROW COLUMN Toggle flag at ROW COLUMN. restart Reset minefield. save FILENAME Save minefield to FILENAME. load FILENAME Load minefield from FILENAME. help Print commands. quit Quit. ")) (defun print-help (&optional (stream t)) "Print help to stream." (format stream "~ NAME Minesweeper. OBJECTIVE Clear the minefield. ") (print-commands stream)) (defun print-newline (&key (count 1) (stream t)) (loop repeat count do (terpri stream))) (defun minesweeper-loop (&key (dimensions '(6 4)) (mine-count 5) (ostream t) (istream nil)) "Minesweeper game loop." (let ((minefield (make-minefield dimensions mine-count))) (loop (print-minefield minefield ostream) (print-newline :count 2 :stream ostream) (format ostream "> ") (force-output ostream) ;; (let ((command (read-from-string (format nil "(~A)" (read-line istream nil))))) (let ((line (read-line istream nil))) (let ((command (read-from-string (format nil "(~A)" line)))) (print-newline :stream ostream) (case (car command) (clear (clear-minefield (cadr command) (caddr command) minefield)) (flag (toggle-flag (cadr command) (caddr command) minefield)) (restart (reset-minefield minefield)) (save (save-minefield minefield (cadr command))) (load (setf minefield (load-minefield (cadr command)))) (help (print-commands ostream) (print-newline :stream ostream)) (quit (return-from minesweeper-loop nil))) (let ((result (end-game-p (car command) (cadr command) (caddr command) minefield))) (when result (print-minefield (reveal-minefield minefield) ostream) (print-newline :count 2 :stream ostream) (format ostream "You ~A!" result) (force-output ostream) (return-from minesweeper-loop t)))))))) (defun minesweeper-cli (&optional (ostream t) (istream nil)) "Minesweeper command line interface." (print-help ostream) (loop (print-newline :stream ostream) (format ostream "Enter minefield dimensions and mine count or press ENTER for defaults, ~ e.g. '6 4 5': ") (force-output ostream) ;; (let ((input (read-from-string (format nil "(~A)" (read-line istream nil))))) (let ((line (read-line istream nil))) (let ((input (read-from-string (format nil "(~A)" line)))) (print-newline :stream ostream) (unless (case (length input) (3 (minesweeper-loop :dimensions (list (car input) (cadr input)) :mine-count (caddr input) :ostream ostream :istream istream)) (2 (minesweeper-loop :dimensions (list (car input) (cadr input)) :ostream ostream :istream istream)) (otherwise (minesweeper-loop :ostream ostream :istream istream))) (return-from minesweeper-cli))) (print-newline :count 2 :stream ostream) (format ostream "Enter 'Y' to play again: ") (force-output ostream) (unless (char-equal (read-char istream) #\Y) (return-from minesweeper-cli))))) ;; Socket Interface (defun minesweeper-socket (stream) "Minesweeper socket interface." (minesweeper-cli stream stream)) (defun minesweeper-server (&key (host "127.0.0.1") (port 8080)) "Minesweeper server." (socket-server host port #'minesweeper-socket nil :multi-threading nil)) ;; ncurses Interface
10,407
Common Lisp
.lisp
234
38.200855
105
0.644379
phua/lisp-games
0
0
0
GPL-3.0
9/19/2024, 11:44:25 AM (Europe/Amsterdam)
ee6c915bdc0988ec14720a061ed235eadeac587f2014a6a12e99479aea6a50ab
37,941
[ -1 ]
37,973
db.lisp
shepherdjerred-homework_deductive-database/test/db.lisp
(setq db '( (T (dog fido)) (T (dog lassie)) ((dog x1) (mammal x1)) ((mammal x2) (wb x2)) ((cat x3) (feline x3)) (T (cat felix)) ((man x4) (mortal x4)) (T (man Socrates)) (T (man Plato)) ((dog x5) (likes Pavlov x5)) ((dog x6) (mortal x6)) ((man x7) (mammal x7)) ((feline x8) (mammal x8)) ((lion x9) (feline x9)) (T (lion leo)) ((feline x10) (mortal x10)) ((likes Pavlov x11) (hates x11 x12)) ((student x13) (hates x13 homework)) (T (student John)) (T (student Mary)) ((dog x14) (hates John))))
580
Common Lisp
.lisp
23
20.434783
40
0.530576
shepherdjerred-homework/deductive-database
0
0
0
GPL-3.0
9/19/2024, 11:44:25 AM (Europe/Amsterdam)
e21a4cc556bce6a0f51edfbcff132adf0c29c23023ddbf9573f2c29d719265ec
37,973
[ -1 ]
37,974
test.lisp
shepherdjerred-homework_deductive-database/test/test.lisp
rprogn (load "../src/unify.lisp") (load "../src/ddb.lisp") (trace unify) (trace ?) (trace prove) (trace query-bool) (trace query-list)) ; DB from Dr. Baird (load "./db.lisp") ; DB for (mortal fido) test (setq db '((T (dog fido)) ((dog x1) (mortal x1)))) ; DB for (likes y fido) test (setq db '((T (dog fido)) ((dog x5) (likes Pavlov x5)))) ; Test ? method (and (equal (? '(mortal x)) '(SOCRATES PLATO FIDO LASSIE FELIX LEO)) (equal (? '(mortal fido)) 'YES) (equal (? '(dog socrates)) 'NO) (equal (? '(likes y fido)) '(PAVLOV)) (equal (? '(hates y fido)) '(FIDO LASSIE JOHN)) (equal (? '(hates fido y)) 'YES) (equal (? '(mammal z)) '(FIDO LASSIE SOCRATES PLATO FELIX LEO)) (equal (? '(wb z)) '(FIDO LASSIE SOCRATES PLATO FELIX LEO)) (equal (? '(dog fido)) 'YES)) ;; Test supporting functions (and (equal (find-vars '(mortal x)) '(x)) (equal (find-vars '(mortal fido)) nil) (equal (find-vars '(likes y fido)) '(y)) (equal (find-vars '(x y z)) '(x y z)) (equal (isvar 'x) T) (equal (isvar 'a) NIL) (equal (type-of-query '(predicate x)) 'LIST) (equal (type-of-query '(predicate a)) 'BOOL) (equal (type-of-query '(predicate x a)) 'LIST) (equal (type-of-query '(predicate a x)) 'BOOL))
1,491
Common Lisp
.lisp
90
12.111111
44
0.523297
shepherdjerred-homework/deductive-database
0
0
0
GPL-3.0
9/19/2024, 11:44:25 AM (Europe/Amsterdam)
d9a1adc258673a77a3494b9714e414cdf5948d98cca5024eaee7bd3e35e2ac45
37,974
[ -1 ]
37,975
ddb.lisp
shepherdjerred-homework_deductive-database/src/ddb.lisp
;;; Takes a term and applies a substitution to it ;;; sub is the form of (X . B) where X is the target and B is the replacement value (defun apply-one-sub (term sub) (let ((sub-key (car sub)) (sub-value (cdr sub))) (if (eq term sub-key) sub-value (if (atom term) term (cons (apply-one-sub (car term) sub) (apply-one-sub (cdr term) sub)))))) ;;; Apply subs to a term ;;; subs follows this form ((X . B)) (defun apply-subs (term subs) (if (atom subs) (apply-one-sub term (car subs)) (apply-subs (apply-one-sub term (car subs)) (cdr subs)))) ;;; Takes an atom and returns T if it is a variable, NIL otherwise (defun isvar (term) (if (member term '(u v w x y z x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20)) t nil)) (defun find-vars (term) (if (atom term) (if (isvar term) term nil) (if (isvar (car term)) (cons (car term) (find-vars (cdr term))) (find-vars (cdr term))))) ;;; Takes a DDB query and returns the type of query it is ;;; query should match one of the below formats ;;; (predicate var) => LIST ;;; (predicate lit) => BOOL ;;; (predicate var lit) => LIST ;;; (predicate lit var) => BOOL (defun type-of-query (query) (if (isvar (cadr query)) 'list 'bool)) ;;; Takes a query and a database ;;; Returns T if the query can be proven, NIL otherwise ;;; This function requires a global database 'db' to be defined (defun prove (query my-db) (let* ((db-entry (car my-db)) (next-db-entry (cdr my-db)) (antecedent (car db-entry)) (consequent (cadr db-entry)) (unify-result (unify query consequent))) (if unify-result (if (eq antecedent t) t (let ((new-query (apply-subs antecedent unify-result))) (if (prove new-query db) t (if (null next-db-entry) nil (prove query next-db-entry))))) (if (null next-db-entry) nil (prove query next-db-entry))))) (defun query-bool (query) (if (prove query db) 'yes 'no)) ;;; Takes a query and a database ;;; Returns a list of symbols that match a query ;;; This function requires a global database 'db' to be defined (defun query-list (query my-db) (let* ((db-entry (car my-db)) (next-db-entry (cdr my-db)) (antecedent (car db-entry)) (consequent (cadr db-entry)) (unify-result (unify query consequent))) (if unify-result (if (eq antecedent t) (append (cdr consequent) (query-list query next-db-entry)) (let ((new-query (apply-subs antecedent unify-result))) (append (query-list new-query db) (query-list query next-db-entry)))) (if (null next-db-entry) 'nil (query-list query next-db-entry))))) (defun ? (query) (if (eq (type-of-query query) 'bool) (query-bool query) (query-list query db)))
2,943
Common Lisp
.lisp
85
29.105882
105
0.611443
shepherdjerred-homework/deductive-database
0
0
0
GPL-3.0
9/19/2024, 11:44:25 AM (Europe/Amsterdam)
2d47328e09575ce3f128856717dfd6ac7b408949abee18e5644ea205c6d0643c
37,975
[ -1 ]
37,996
C2M-class.lisp
JRSV_C2M/C2M-class.lisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Chord to Measure or C2M is a collection of methods that produce ;; musical material according to shuffling rules that determin the structure ;; pitch / rhythm / form ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Functions used in C2M class ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun remove-by-idx (idx list) (loop for elt in list for i from 0 unless (= i idx) collect elt)) (defun chord-place-in-measure (in-chord in-order) (let* ((chord in-chord) (map-with in-order) (len) (dist '())) (setq len (length chord)) (loop for i from 0 to (- len 1) do (setq dist (econs dist (position i map-with)))) dist)) (defun ts-from-chord-length (amount-of-beats rthm-fig) (let* ((base rthm-fig) (chord amount-of-beats) (number-of-units) (ts '())) (setq number-of-units (length chord)) (setq ts (push base ts)) (setq ts (push number-of-units ts)) ts)) (defun pack-in-measures (in-list-of-notes in-measure-length) (let* ((notes in-list-of-notes) (measure-len in-measure-length) (measure '()) (music '()) grouping group grp) (setq grouping (split-groups (length notes) measure-len)) (setq grp 0) (loop for note in notes for place from 1 to (length notes) do (push note measure) (setq group (nth grp grouping)) ;;(format t "~% ~a ~a" group note) (cond ((and (= (length measure) group) (= (length measure) measure-len)) (setq measure (nreverse measure)) (push measure music) (setq measure '()) (setq grp (1+ grp))) ((and (= (length measure) group) (not (equal (length measure) measure-len))) (loop repeat (- measure-len (length measure)) do (push 'r measure)) (setq measure (nreverse measure)) (push measure music) (setq measure '()) (setq grp (1+ grp)) ))) (setq music (nreverse music)) music)) (defun 2-note (in-chord) (let* ((chord (list in-chord))) (setq chord (flatten chord)) (if (and (listp chord) (= (length chord) 1)) (progn ;;(print "here") (setq chord (midi-to-note (first chord))) ) (progn ;;(print "there") (setq chord (loop :for note :in chord :collect (midi-to-note note))) )) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; The DATA STRUCTURE of the C2M class ;;___________________________________________________________________________ (defclass C2M () ((chord :accessor C2M-chord) (unit :accessor C2M-beat-unit) (order :accessor C2M-order) (measures :accessor C2M-measures) (time-sig :accessor C2M-time-sig) (req-ratio :accessor C2M-req-ratio) (path :accessor C2M-path) (name :accessor C2M-name) ;; initform (C2M-time-sig )) ;; need to figure out initform ;; Methods (one-note-out :reader one-note-out) (shrink-chord :reader shrink-chord) (grab-and-pass :reader grab-and-pass) (deal-from-chord :reader deal-from-chord) (requantize :reader requantize) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Places the chord in the squence, according to the order given. It uses a ;; distribution list based on the function "chord-place-in-measure" which ;; should populate a slot in the C2M structure ;; ;wooden-box class inherits the box class ;;___________________________________________________________________________ (defmethod chord-in-order ((object C2M)) (let* ((chord (C2M-chord object)) (order (C2M-order object)) (beat-dur (C2M-beat-unit object)) (time-sig (C2M-time-sig object)) (bar '()) (dist '()) (measures)) (setq time-sig (ts-from-chord-length chord beat-dur)) (setq dist (chord-place-in-measure chord order)) (loop repeat (length chord) for n from 0 do (setq bar '()) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (loop for i from 0 to (- (length chord) 1) do (if (= (nth n dist) i) (progn (format nil "~%PLACE IN : ~a CYCLE : ~a" (nth n dist) i) ;;;;; here we process what we want;;;;;;;;;;;;;;;;;;;;;;;;;; (setq bar (push chord bar))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq bar (push 'R bar)))) (setq bar (nreverse bar)) (setq measures (push bar measures))) (setq measures (nreverse measures)) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Places the (chord - 1 note) according to "place-in-measure" ;; allows the possibility of using the "missing note" for the vibe ;;___________________________________________________________________________ (defmethod one-note-out ((object C2M)) (let* ((chord (C2M-chord object)) (order (C2M-order object)) (time-sig (C2M-time-sig object)) (beat-dur (C2M-beat-unit object)) (bar '()) (dist '()) (measures) note-out-chord) (setq time-sig (ts-from-chord-length chord beat-dur)) (setq dist (chord-place-in-measure chord order)) (loop repeat (length chord) for n from 0 do (setq bar '()) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (loop for i from 0 to (- (length chord) 1) do (format nil "~%PLACE IN : ~a CYCLE : ~a" (nth n dist) n) (if (= (nth n dist) i) (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; process what we want we build the chord as we need ;; and make the event at the bottom (setq note-out-chord (remove-by-idx n chord)) (setq bar (push note-out-chord bar))) (setq bar (push 'R bar)))) (setq bar (nreverse bar)) (setq measures (push bar measures))) (setq measures (nreverse measures)) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; C2M Shrinks the chord by (-1) pitch in each cycle ;;___________________________________________________________________________ (defmethod shrink-chord ((object C2M)) (let* ((chord (C2M-chord object)) (order (C2M-order object)) (time-sig (C2M-time-sig object)) (beat-dur (C2M-beat-unit object)) (bar '()) (dist '()) (measures '()) len (new-chord) (deleted-note)) (setq len (- (length chord) 1)) (setq time-sig (ts-from-chord-length chord beat-dur)) (setq dist (chord-place-in-measure chord order)) (setq new-chord chord) (loop repeat (length chord) for n from 0 do ;; bar number (setq bar '()) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (loop for i from 0 to (- (length chord) 1) do (if (= (nth n dist) i) (setq bar (push new-chord bar)) (setq bar (push 'R bar)) )) (setq deleted-note (nth n chord)) (setq new-chord (remove deleted-note new-chord)) (setq bar (nreverse bar)) (push bar measures)) (setq measures (nreverse measures)) )) ;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; C2M will place the chord in the determined place but will leave behind 1 ;;___________________________________________________________________________ (defmethod grab-and-pass ((object C2M)) (let* ((chord (C2M-chord object)) (order (C2M-order object)) (time-sig (C2M-time-sig object)) (beat-dur (C2M-beat-unit object)) (bar '()) (dist '()) (measures '()) (len) (rest-of-chord) (place-to-edit) (cur-measure) (prev-measure) beat-to-rmv) (setq len (- (length chord) 1)) (setq time-sig (ts-from-chord-length chord beat-dur)) (setq dist (chord-place-in-measure chord order)) (setq rest-of-chord chord) (setq prev-measure (loop for rest from 0 to len collect 'r)) (loop for m-number from 0 to len do (setq place-to-edit (nth m-number dist)) (setq cur-measure prev-measure) (loop for beat from 0 to len do (when (= beat place-to-edit) ;; beat to extract from rest-of-chord (setq beat-to-rmv (nth m-number chord)) ;; insert chord in "place-to-edit" (setf (nth place-to-edit cur-measure) rest-of-chord) (setq bar (copy-list cur-measure)) (setf (nth beat cur-measure) beat-to-rmv) (setq rest-of-chord (remove beat-to-rmv rest-of-chord)) )) (push bar measures)) (setq measures (nreverse measures)) )) ;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; C2M chord remains fixed in position but deals a note in each cycle ;;___________________________________________________________________________ (defmethod deal-from-chord ((object C2M)) (let* ((chord (C2M-chord object)) (order (C2M-order object)) (time-sig (C2M-time-sig object)) (beat-dur (C2M-beat-unit object)) (dist '()) (measures '()) len (rest-of-chord) (place-to-edit) (cur-measure) (prev-measure) (measure '()) note-to-rmv) (setq len (- (length chord) 1)) (setq time-sig (ts-from-chord-length chord beat-dur)) (print (setq dist (chord-place-in-measure chord order))) (setq rest-of-chord chord) ;;create the base measure, full of rests (setq prev-measure (loop for rest from 0 to len collect 'R)) (loop for m-number from 0 to len do (setq place-to-edit (nth m-number dist)) (setq cur-measure prev-measure) ;; inserts complete chord in beat of first itiration. (if (= m-number 0) (progn ;;(format t "~%MEASURE Number ~a" m-number) (setf (nth (nth 0 dist) cur-measure) chord) ;;(format t "~%--- ~a ---" cur-measure) ;;(setq measures (push cur-measure measures)) ) (progn ;;(format t "~%MEASURE Number ~a" m-number) (setq note-to-rmv (nth 1 rest-of-chord)) (setq rest-of-chord (remove note-to-rmv rest-of-chord)) (setf (nth (nth 0 dist) cur-measure) rest-of-chord) (setf (nth (nth m-number dist) cur-measure) note-to-rmv) )) (setq measure (copy-list cur-measure)) (setq measures (push measure measures))) (setq measures (nreverse measures)) )) ;; ;;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; C2M REQUANTIZE ;;___________________________________________________________________________ (defmethod requantize ((object C2M)) (let* ((measures (C2M-measures object)) ;;(beat-dur (C2M-beat-unit object)) ;;(time-sig (C2M-time-sig object)) (req-ratio (C2M-req-ratio object)) (out-measures '()) bt bar (bars '())) (loop for measure in measures do (setq bar '()) (loop for beat in measure do (cond ((not(equal beat 'R)) ;; we get rid of "chords of 1 note" (if (and (listp beat) (= (length beat) 1)) (setq bt (first beat)) (setq bt beat)) (loop repeat req-ratio do (setq bar (push bt bar)))) ((equal beat 'R) (loop repeat req-ratio do (setq bar (push 'R bar))) ))) (setq bar (nreverse bar)) (push bar bars)) (loop for bar in bars do (loop for beat in bar do (push beat out-measures) )) out-measures )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; C2M bar format -> Slippery Chicken -> Lilypond. It provides a sc ;; object full of events and will be named as it is in. Renders the ;; music to a local ;; file. ;;______________________________________________________________________ (defmethod render-local ((object C2M)) (let* ((measures (C2M-measures object)) (beat-dur (C2M-beat-unit object)) (path (C2M-path object)) (name (C2M-name object)) (time-sig (C2M-time-sig object)) (out-measures '()) (ties '()) (prev-tie '(0 0 0)) (next-tie 0) (prev-note 0) bar output-score event-number note-event curr-tie tie) ;; this loop creates the information of notes tied to ;; consolidate repeats (setq ties '()) (loop for measure in measures for m-number from 0 do (loop for beat in measure for b-number from 0 do (setq tie '()) (setq tie (push b-number tie)) (cond ((not (equal beat 'R)) (setq tie (push 1 tie) tie (push (2-note beat) tie))) ((equal beat 'R) (setq tie (push 0 tie) tie (push beat tie)))) (setq tie (nreverse tie)) (push tie ties))) (setq ties (nreverse ties)) (setq event-number 0) (print time-sig) (setq m-number 0) ;;;;; (loop for measure in measures do (incf m-number) (format t "~% ................. Measure ~a" m-number) ;; (setq beat-dur (* (/ (length measure) (nth 0 time-sig)) ;; (nth 1 time-sig))) (format t "~%+++++++++++++++++++++++ ~a ~a ~%~a " beat-dur (length measure) measure) (setq bar '()) (loop for beat in measure for b-number from 1 do (setq curr-tie (nth event-number ties)) (setq next-tie (nth (+ event-number 1) ties)) (if (equal beat 'R) (progn (format t "~% ~a ************************************** REST" b-number) (format t "~%E#: ~a | Prev Tie: ~a | Tie: ~a | Next Tie: ~a |" (+ event-number 1)(nth 1 prev-tie) (nth 1 curr-tie)(nth 1 next-tie)) (format t "~% -------------------- * SILENCE *") (setq bar (push (make-event nil beat-dur :is-rest t) bar))) (progn (format t "~% ~a ************************************** NOTE" b-number) (format t "~%E#: ~a | Prev Tie: ~a | Tie: ~a | Next Tie: ~a |" (+ 1 event-number) (nth 1 prev-tie) (nth 1 curr-tie) (nth 1 next-tie)) (format t "~%Prev: ~a~%Curr: ~a~%Next: ~a~%" (nth 2 prev-tie) (nth 2 curr-tie) (nth 2 next-tie)) (when (and (not (equal (nth 2 prev-tie) (nth 2 curr-tie))) (not (equal (nth 2 curr-tie) (nth 2 next-tie)))) (setq bar (push (make-event (2-note beat) beat-dur :is-tied-to nil :is-tied-from nil ) bar))) (when (and (not (equal (nth 2 prev-tie) (nth 2 curr-tie))) (equal (nth 2 curr-tie) (nth 2 next-tie))) ;;(format t " -------------------- * FIRST *") ;;(format t "~% --") (setq bar (push (make-event (2-note beat) beat-dur :is-tied-to t :is-tied-from t ) bar))) (when (and (equal (nth 2 prev-tie) (nth 2 curr-tie)) (equal (nth 2 curr-tie) (nth 2 next-tie))) ;;(format t " -------------------- * MIDDLE") ;;(format t "~% --") (setq bar (push (make-event (2-note beat) beat-dur :is-tied-to t :is-tied-from t ) bar))) (when (and (equal (nth 2 prev-tie) (nth 2 curr-tie)) (not (equal (nth 2 curr-tie) (nth 2 next-tie)))) ;;(format t "~% ------------------- * LAST") ;;(format t "~% --") (setq bar (push (make-event (2-note beat) beat-dur :is-tied-to t :is-tied-from nil ) bar))))) (incf event-number) (setq prev-tie (nth (- event-number 1) ties))) (setq bar (nreverse bar)) (format t "~%LENGTH BAR : ~a" (length bar)) (setq bar (make-rthm-seq-bar (push time-sig bar))) ;;(setq bar (consolidate-notes bar)) ;;(setq bar (consolidate-rests bar)) (push bar out-measures)) (setq out-measures (nreverse out-measures)) )) ;;; - examples - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; we fill some slots of the DATA STRUCTURE and create the sequence (setq C2M_example_seq (make-instance 'C2M)) (setf (C2M-chord C2M_example_seq) '(60 62 69 76 81)) (setf (C2M-order C2M_example_seq) '(4 2 0 3 1)) (setf (C2M-time-sig C2M_example_seq) '(5 8)) (setf (C2M-beat-unit C2M_example_seq) 32) (setf (C2M-path C2M_example_seq) "~/Desktop/Test") (setf (C2M-name C2M_example_seq) "A1") ;; Produces the different sequence of each method (chord-in-order C2M_example_seq) (grab-and-pass C2M_example_seq) (shrink-chord C2M_example_seq) (one-note-out C2M_example_seq) (deal-from-chord C2M_example_seq) ;; clear measures slot (setq measures '()) (setf (C2M-measures C2M_example_seq) measures) (print (C2M-measures C2M_example_seq)) ;; I call a method to generate a sequence (setq measures (grab-and-pass C2M_example_seq)) ;; then I populate that slot with the previous result ;; so my data structure has the measure slot full (setf (C2M-measures C2M_example_seq) measures) (setf (C2M-beat-unit C2M_example_seq) 16) (setf (C2M-req-ratio C2M_example_seq) 2) ;; I can call the requantize method to expand (setf (C2M-measures C2M_example_seq) ;; measures are packed according to the relationship they expand ;; and the unit used inside the original measure (pack-in-measures (requantize C2M_example_seq) 10)) (print (C2M-measures C2M_example_seq)) (C2M-time-sig C2M_example_seq) (setq bars(render-local C2M_example_seq)) (midi-play (bars-to-sc (render-local C2M_example_seq))) (lp-display (bars-to-sc (render-local C2M_example_seq))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17,250
Common Lisp
.lisp
468
31.933761
87
0.534246
JRSV/C2M
0
0
0
GPL-3.0
9/19/2024, 11:44:25 AM (Europe/Amsterdam)
476e1fdbfef4896d7889ea3a4401f51cb1e8fd14cae88291474be1b9ca281238
37,996
[ -1 ]
38,014
simulation.lisp
Jean-4k_2generals1problem/simulation.lisp
(defparameter verbeux? t) (defclass général () ((nom :initarg :nom :initform (error "Veuillez spécifier un nom de général.") :accessor nom) (nb-envoyés :initarg :nb-envoyés :initform 0 :accessor nb-envoyés) (nb-reçus :initarg :nb-reçus :initform 0 :accessor nb-reçus) (heure-attaque :initarg :heure-attaque :initform nil :accessor heure-attaque))) (defun créer-général (nom) (make-instance 'général :nom nom)) (defun réinitialiser-général (général &key (sauf-nb-envoyés nil)) (unless sauf-nb-envoyés (setf (nb-envoyés général) 0)) (setf (nb-reçus général) 0) (setf (heure-attaque général) nil)) (defun envoi-réussi? () (= (random 2) 1)) (defun message-succès-réception (général) (when verbeux? (format t "Le général ~a a reçu un message, total:~a.~%" (nom général) (nb-reçus général)))) (defun message-échec-envoi (général1 général2) (when verbeux? (format t "Le message de ~a vers ~a a échoué.~%" (nom général1) (nom général2)))) (defun message-succès-envoi (général) (when verbeux? (format t "Message envoyé par le général ~a.~%" (nom général)))) (defun message-échec-confirmation (général) (when verbeux? (format t "Le message de confirmation envoyé par le général ~a a échoué...On recommence.~%" (nom général)))) (defgeneric envoyer (général1 général2)) (defmethod envoyer ((général1 général) (général2 général)) ;; Le général 1 a bien envoyé un message. (when (string= (nom général1) "A") (incf (nb-envoyés général1))) (message-succès-envoi général1) (if (envoi-réussi?) (progn ;; Le général 2 a bien reçu un message. (incf (nb-reçus général2)) (message-succès-réception général2) ;; Le général 2 récupère l'heure d'attaque. (setf (heure-attaque général2) "15h00") (when (< (nb-reçus général2) 2) ;; Le général 2 a bien envoyé un message. (when (string= (nom général2) "B") (incf (nb-envoyés général2))) (envoyer général2 général1))) (progn (message-échec-envoi général1 général2) (if (string= (nom général1) "A") (envoyer général1 général2) (progn (réinitialiser-général général1 :sauf-nb-envoyés t) (réinitialiser-général général2 :sauf-nb-envoyés t) (message-échec-confirmation général1) (envoyer général2 général1)))))) (defun tester-discussion (général1 général2 &key (verbeux? t)) (envoyer général1 général2) (when verbeux? (format t " Heure attaque de ~a (~a envois): ~a.~% Heure attaque de ~a (~a envois): ~a.~%~%" (nom général1) (nb-envoyés général1) (heure-attaque général1) (nom général2) (nb-envoyés général2) (heure-attaque général2))) (and (string= (heure-attaque général1) "15h00") (string= (heure-attaque général2) "15h00"))) (defun tester* (n &key (verbeux? nil)) (unless (>= n 1) (error "Veuillez indiquer un nombre de tests >= 1.")) (let ((A (créer-général "A")) (B (créer-général "B"))) (if (reduce #'(lambda (x y) (and x y)) (loop for i from 1 to n collect (let ((résultat (tester-discussion A B :verbeux? verbeux?))) (réinitialiser-général A) (réinitialiser-général B) résultat))) (format t "Tests valides : ~a/~a.~%" n n) (format t "L'un des tests a échoué.~%")))) (defun tester (n &key (verbeux? nil)) (time (tester* n :verbeux? verbeux?)))
3,560
Common Lisp
.lisp
95
31.4
95
0.673225
Jean-4k/2generals1problem
0
1
0
GPL-2.0
9/19/2024, 11:44:25 AM (Europe/Amsterdam)
9d49e114f4289a11e45f69ea3134fa15250f34631f389316df8f68bd6bbe6012
38,014
[ -1 ]
38,032
dilemma.lsp
macropeter_Lisp-Trials/dilemma.lsp
; Juli 2011 ; Eigenes Konzept nach "Land of Lisp" Kapitel 9 ; Neuaufnahme: Jänner 2013 (defvar *matrix* (list (list (cons 1 1) (cons 0 5)) (list (cons 5 0) (cons 3 3)))) (defparameter *erg-liste* nil) ;history zum Auswerten für die Teilnehmer ;das letzte Erebnis wird vorne angehängt (defun clear-ergebnisse () (setq *erg-liste* nil)) ;das allg Spielerobjekt (defstruct spieler (history nil) ; (gewinn 0)) ; letzte Gewinnüberweisung ; der gemeine Zufallsspieler (defmethod setze-spieler (s) "::Spieler->Bool; Handlung des Spielers: betrügen (nil) oder kooperieren (T)" (if (zerop (random 2)) nil T)) (defmethod rueckmeld-spieler (s gew) (setf (spieler-gewinn s) gew)) (defun spiel1 (sp1 sp2) "::spieler->spieler->(gewinn . gewinn); zwei Spieler setzen gegeneinander" (let ((x (setze-spieler sp1)) (y (setze-spieler sp2))) (let ((erg (cond ((and x y) (cons 3 3)) ((and (not x) y) (cons 5 0)) ((and x (not y)) (cons 0 5)) (T (cons 1 1))))) (push erg *erg-liste*) ;Seiteneffekt: history updaten (rueckmeld-spieler sp1 (car erg)) ;Seiteneffekt: Rückmeldung an Spieler (rueckmeld-spieler sp2 (cdr erg)) erg))) (defstruct (nihilist (:include spieler))) (defmethod setze-spieler ((s nihilist)) nil) ; betrügt immer (defstruct (alternator (:include spieler)) zuletzt) ;Spieler mit Gedächtnis für die letzte Runde ;spielt alternierend (defmethod setze-spieler ((s alternator)) (not (alternator-zuletzt s))) (defun auswertung (ergliste) "::(ergebnisse)->[sum1 sum2]: Berechnen der Summen" (let ((sum1 (apply #'+ (mapcar #'car ergliste))) (sum2 (apply #'+ (mapcar #'cdr ergliste)))) ;Seiteneffekt: Ergebnis ausgeben (princ "Summe Spieler 1 = ") (princ sum1) (terpri) (princ "Summe Spieler 2 = ") (princ sum2) (terpri) (princ "Gesamtergebnis = ") (princ (+ sum1 sum2)) ;Ergebnis zurückgeben (cons sum1 sum2))) (defun duell (a b n) (loop for i below n collect (spiel1 a b))) ;(auswertung (duell a b 10)) ;------------------ Baustelle --------------------------- (defstruct (tit4tatter (:include spieler)) zuletzt) (defmethod setze-spieler ((s tit4tatter)) ; (let ((zuz (tit4tatter-zuletzt s)) (if (tit4tatter-zuletzt s) (setf (tit4tatter-zuletzt s) nil) (setf (tit4tatter-zuletzt s) T))) ;------------------ Archiv ------------------------------ (defun spiel (x y) "::Bool->Bool->(gewinn . gewinn); zwei Spieler setzen gegeneinander" (cond ((and x y) (push (cons 3 3) *erg-liste*)) ((and (not x) y) (push (cons 5 1) *erg-liste*)) ((and x (not y)) (push (cons 1 5) *erg-liste*)) (T (push (cons 1 1) *erg-liste*))))
2,856
Common Lisp
.l
71
34.239437
81
0.608221
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
5345ac2ace6d4b5ba7e258cf42b1df2ac9da07a136cee9ad5d465af3341a2b0a
38,032
[ -1 ]
38,033
bogo.lsp
macropeter_Lisp-Trials/bogo.lsp
; BogoSort (oder StupidSort) nach www.blödsort.de ; März 2011 ; Oktober 2011 (defun istSortiert (LL) "Prüft nach, ob eine Liste sortiert ist" (cond ((null (cdr LL)) T) ;nur noch ein Element in der Liste (T (and (< (car LL) (cadr LL)) (istSortiert (cdr LL)))))) (defun ListeOhneN (n LL) (if (zerop n) (cdr LL) (cons (car LL) (ListeOhneN (1- n) (cdr LL))))) (defun holeNthHeraus (n LL) "Liste aus dem nth und der restlichen Liste: mit car erhält man das Element, mit second die Liste ohne das Element" (list (nth n LL) (ListeOhneN n LL))) (defun list1bisN (n) "Liste von 1..n" (do ((i n (1- i)) (erg nil (cons i erg))) ((= i 0) erg) nil)) (defun permutation (LL) "Eine zufällige Permutation einer eingegebenen Liste erzeugen" (labels ((permutationHelp (LL OutLL) (if (null LL) OutLL (let ((redux (holeNthHeraus (random (length LL)) LL))) (permutationHelp (second redux) (cons (car redux) OutLL)))))) (permutationHelp LL nil))) (defun bogosort (LL) "Sortieren durch Erzeugen zufälliger Permutationen solange bis eine Sortierung entstanden ist; Achtung: terminiert unter Umständen gar nicht und hat eine entsetzliche Performance!" (if (istSortiert LL) LL (bogosort (permutation LL)))) ; Oktober 2011 (defun liste1n (n) ;leider verkehrt herum (unless (zerop n) (cons n (liste1n (1- n))))) (defun liste1nn (x) ;richtige Reihenfolge "Liste von 1..x, ohne do aber mit lokaler Fkt" (labels ((helper (n) (unless (zerop n) (cons n (liste1n (1- n)))))) (reverse (helper x))))
1,744
Common Lisp
.l
43
33.139535
182
0.623565
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
b9449e629086fee8c9cd7472060a3e334406e009be0def32db1da409a53559b0
38,033
[ -1 ]
38,034
Kapitel2.lsp
macropeter_Lisp-Trials/Kapitel2.lsp
(let ((direction 'up)) (defun toggle-counter-direction () (setq direction (if (eq direction 'up) 'down 'up))) (defun counter-class () (let ((counter 0)) (lambda () (if (eq direction 'up) (incf counter) (decf counter))))))
303
Common Lisp
.l
12
17.5
36
0.503448
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
fa0cda4dc5ea323361c29c31b440cb407db7d537fc2e29431ade45665c50c418
38,034
[ -1 ]
38,035
neumann.lsp
macropeter_Lisp-Trials/neumann.lsp
; Neumanngenerator (wieviele Bit hat eigentlich Integer bei Lisp?) ; Jänner 2011 ; vgl. das baugleiche Haskellprogramm ; ganzzahlige Division (defun div (x y) (truncate (/ x y))) ; ganzzahlige Division, manuell gestrickt: ist aber bei großen Zahlen zu langsam! (defun divi (x y) (do ((z 0 (1+ z)) (r x (- r y))) ((< r y) z) ())) ; ganzzahlige Division, rekursive Variante: meist Überlauf... (defun rdivi-hilf (x y z) (if (< x y) z (rdivi (- x y) y (1+ z)))) (defun ndivi (x y) (rdivi-hilf x y 0)) (defun next-neumann (x) (mod (div (* x x) 256) 65536)) ; rekursiv: Haskell-style (defun neumann2 (x n) (let ((y (next-neumann x))) ;body: (if (= n 0) nil (cons y (neumann y (1- n)))))) (defun r-neumann (x n) (if (= 0 n) nil (cons x (r-neumann (next-neumann x) (1- n))))) ; dotimes: mit setf-Zuweisungen (defun neumann3 (x n) (reverse (let ((erg nil) (y x)) (dotimes (i n erg) (setf erg (cons y erg)) (setf y (nextneumann y)) )))) ; Lisp-style mit do, dem Schweizermesser der Iteration (defun neumann (x n) (reverse (do* ((i 1 (1+ i)) ;Schleifenzähler (y x (next-neumann y)) ;Neumannzahl (erg (list y) (cons y erg))) ;Zahlenliste ;test ;Rückgabe ((= i n) erg) ;body (leer) ()))) ; dasselbe mit lokal definierter Funktion (defun neumann (x n) (reverse (labels ((nextneumann (x) (mod (div (* x x) 256) 65536))) (do* ((i 1 (1+ i)) ;Schleifenzähler (y x (nextneumann y)) ;Neumannzahl (erg (list y) (cons y erg))) ;Zahlenliste ;test ;Rückgabe ((= i n) erg) ;body (leer) ()))))
1,978
Common Lisp
.l
58
24.724138
84
0.507825
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
0e8ac4a3e4e85c90fab241ca1dff6e2c08e03cea547830f8fc0a77f9c13b9473
38,035
[ -1 ]
38,036
ziegenp.lsp
macropeter_Lisp-Trials/ziegenp.lsp
; Das Ziegenproblem als OOP-Beispiel ; Oktober 2014 (defclass tuer () ((treffer :accessor treffer :initform nil :documentation "Ziege (nil) oder Auto") (offen :accessor offen :initform nil :documentation "Tür geöffnet oder nicht (nil)"))) (setq *tueren* (make-array 3 :element-type 'tuer)) ; Array mit 3 Türen (loop for i below 3 do (setf (aref *tueren* i) (make-instance 'tuer))) ; Objekte initialisieren (setf (treffer (aref *tueren* (random 3))) T) ; eine zufällige Tür als Treffer auswählen (defun prompt-read (prompt) (format *query-io* "~a: " prompt) (read-line *query-io*)) (defun rate () (null (treffer (aref *tueren* (prompt-read "0, 1 oder 2:")))))
721
Common Lisp
.l
18
35.722222
88
0.672464
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
6506f74795d679c21ba4fc73250b095dd70e672502321ec3bd985e8178807e21
38,036
[ -1 ]
38,037
irrfahrt.lsp
macropeter_Lisp-Trials/irrfahrt.lsp
; Die klassische Irrfahrt ; März 2011 (defparameter *guthaben* 0) (defun guthaben0 () (setq *guthaben* 0)) (defun einspiel () (if (= (random 2) 0) (setq *guthaben* (1+ *guthaben*)) (setq *guthaben* (1- *guthaben*)))) (defun irrfahrt (n) ;fast deklarative Variante (progn (guthaben0) (dotimes (i n 'done) (progn (einspiel) (format t "~A ~%" *guthaben*)) ))) (defun irrfahrt2 (n) ;eher funktional: aber mit globVar (do ((i 1 (1+ i)) (erg nil (cons *guthaben* erg))) ((> i n) (reverse erg)) ;Rückgabe: umgedrehte Liste (format t "~A ~%" (einspiel)))) (defun f-einspiel nil ; f(unktionales)-einspiel (if (= (random 2) 0) 1 -1)) (defun irrfahrt3 (n) ;arbeitet nur mit lokalen Vars (do ((i 1 (1+ i)) (guthaben 0 (+ guthaben (f-einspiel))) (erg nil (cons guthaben erg))) ((> i n) (reverse erg)) ; gibt am Ende das Ergebnis als Liste (format t "~A ~%" guthaben))) ;body: Ausgabe
1,091
Common Lisp
.l
27
32.148148
70
0.538023
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
773a1bbf03d3e3526b2a50599fa2cf79e9580c2c09d2c467dc82612b309b9c11
38,037
[ -1 ]
38,038
fibo.lsp
macropeter_Lisp-Trials/fibo.lsp
;Fibonaccizahlen, verschiedene Varianten ;letzte Bearbeitung: April 2011 ;klassisches, sehr ineffektives Verfahren: (defun fibo (x) (cond ((= x 0) 0) ((= x 1) 1) (T (+ (fibo (- x 1)) (fibo (- x 2))))) ) (defun fibolist (n erglist) "Liste von n Fibonaccizahlen: Aufruf mit n und nil" (cond ((= 0 n) erglist) (T (fibolist (- n 1) (cons (fibo n) erglist)) ) )) ;********************************************************** ;deutlich effektiveres Verfahren: ;jeweils 2 Folgenglieder erzeugen und somit speichern (defun fiboStep (x2) (let ((u (first x2)) (v (second x2)) ) (list v (+ u v)) ) ) (defun fiboPair (n) (cond ((= n 0) (list 0 1)) (T (fiboStep (fiboPair (- n 1)))) ) ) ;********************************************************* ;Effektive Variante, fast lazy, ganze Liste aufbauen (defun fibo-Steps (n LL) "Liste der n Fibonaccizahlen, sehr effektive, endrekursive Variante Aufruf mit n und '(1 1)" (if (= 2 n) LL ;Ende der Rekursion (fibo-steps (1- n) (cons (+ (car LL) (cadr LL)) LL)))) (defun fibo-nth (n) "Berechnet die n-te Fibonaccizahl" (car (fibo-steps n '(1 1))))
1,298
Common Lisp
.l
43
24.162791
59
0.50641
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
7b7898915c487493c66487cfe2da50b8ef939d0ae4efe2de3011c1e135447555
38,038
[ -1 ]
38,039
ls1.lsp
macropeter_Lisp-Trials/ls1.lsp
; Dez-Jän 2013 ; WebUntis-csv-Dateien mit Schülerlisten einlesen und ; als xml-Dateien wieder ausgeben (defstruct schueler name vorname klasse zweig faecher) (setq *my-stream* "schueler.txt") (defun str2text (txt) ; Trafo von Symbol in Text mit großem Anfangsbuchstaben (string-capitalize (string-downcase (string txt)))) (defun liesn (datei) "Von einer Webuntis-csv-Datei die Namen einlesen und als Liste zurückgeben den Rest der Zeile jeweils verwerfen" (with-open-file (my datei :direction :input :if-does-not-exist nil) (read-line my) ;Kopfzeile überspringen (do ((l1 (read my) (read my nil 'eof)) ;1.Wort lesen, :type Symbol (l2 (read my) (read my nil 'eof)) ;2.Wort lesen (nur der 1.Vorname gelesen) (ldummy (read-line my) (read-line my nil 'eof)) ;Rest der Zeile lesen und verwerfen (llist nil (cons (make-schueler :name (str2text l1) :vorname (str2text l2)) llist))) ((eq l1 'eof) llist) ;Abbruchbedingung Lesevorgang am Ende der Datei ()))) (defun erweitere (LL kl jg fach &optional fach2) (mapcar (lambda (x) (setf (schueler-zweig x) kl) (setf (schueler-klasse x) jg) (setf (schueler-faecher x) (list fach))) ;mehrere Fächer mögl, deshalb Liste LL) (reverse LL)) ;zurückgeben (setf gibt sonst nur die letzte Eigenschaft zurück) (defun schreibs (LL) "Ausgabe der Schülerliste im XML-Format Eingabe: Liste von SchülerInnen-Records (siehe defstruct)" (if (null LL) T (let ((sinfo (car LL))) ;1.Datensatz einlesen (format t "~%<schuelerIn>~%") (format t "<name>~A</name>~%" (schueler-name sinfo)) (format t "<vorname>~a</vorname>~%" (schueler-vorname sinfo)) (format t "<zweig>~A</zweig>~%" (schueler-zweig sinfo)) (format t "<jahrgang>~A</jahrgang>~%" (schueler-klasse sinfo)) (format t "<fach>~a>/fach>~%" (car (schueler-faecher sinfo))) (format t "<aktiv>1</aktiv>~%") (format t "</schuelerIn>~%") (schreibs (cdr LL))))) ;Rekursion: Rest der Datensätze ; (schreibs (erweitere (liesn "datei.txt") "A" 8 "Philo"))
2,095
Common Lisp
.l
41
46.04878
86
0.678325
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
3b81d66b7af4758081d399f105486942d4c4ca987a5f38c813d1e4d7a5985c62
38,039
[ -1 ]
38,040
bubble.lsp
macropeter_Lisp-Trials/bubble.lsp
; BubbleSort-Variationen ; Mai 2010 ;Innere Schleife: das größte Element wandert ans Ende (defun bubblehelper (x2) (cond ((null x2) nil) ;falls leer, nil zurück ((= (length x2) 1) x2) ;falls nur ein Element:als Liste zurück (T (let ((x (first x2)) ;1.Element (y (second x2)) ;2.Element (rest (cdr (cdr x2)))) ;Rest der Liste (cond ((> x y) (cons y (bubblehelper (cons x rest)))) (T (cons x (bubblehelper (cons y rest)))) ) ) ) ) ) ;äußere Schleife (n-1) Durchgänge (defun bubbleS (n LL) (cond ((= n 0) LL) ;von bubblehelper organisieren (T (bubbleS (- n 1) (bubblehelper LL))) ) ) ;Starter für BubbleS (defun bubbleSort (Liste) (bubbleS (- (length Liste) 1) Liste) ) ;--------------------------------------------------- (defun bubble (LL) (let ((x (first LL)) (y (second LL)) (xy (bubblehelper (list x y))) (rest (cdr (cdr LL)))) (rest) ) )
1,113
Common Lisp
.l
37
22.783784
74
0.490476
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
f39c52da5ff49caa1cab81c0dd4bc69c67bf958b6a83a1949a79e7a14c84f694
38,040
[ -1 ]
38,041
Jacobi.lsp
macropeter_Lisp-Trials/Jacobi.lsp
;;Der Solovay-Strassen-Test für Primzahlen: ;;Ein MC-Verfahren! (defun qTest (n x m) "Test ob n ein qu Rest von x mod m ist" (eq (mod (* n n) m) x)) (defun test2 (x m) "gibt List aller quadratischen Rest von x mod m zurück" (loop for i from 2 to (1- m) when (qTest i x m) collect i)) (defun exptm (x n m) "ganzahlige Potenz modulo m: x hoch n mod m" (if (zerop n) 1 (mod (* x (exptm x (1- n) m)) m))) (defun pseudoprim (x n) "berechnet b=x^(n-1)/2 mod n" (exptm x (/ (1- n) 2) n))
583
Common Lisp
.l
24
19.041667
57
0.561694
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
174d5e01636687e024e872a700890524bd202f6c88110d27e03de0bf1e0ae271
38,041
[ -1 ]
38,042
nest.lsp
macropeter_Lisp-Trials/nest.lsp
(defun bsp (x) (* 2 x)) (defun nest (f x n) (cond ((eq n 0) (funcall f x)) (T (nest f (funcall f x) (1- n))))) (defun nestlist (f x n) (cond ((eq n 0) (funcall f x)) (T (nest f (funcall f x) (1- n)))))
236
Common Lisp
.l
8
24.25
41
0.471366
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
230bd94a55f21ded751072d37e3af270174b3cfa43fe9a7eee7f7a2ea90be594
38,042
[ -1 ]
38,043
mksa.lsp
macropeter_Lisp-Trials/mksa.lsp
;;;MKSA = Meter kg Sek Ampere ;;; Grunddeinheiten der Mechanik ;;; nach Krusenotto Anwendungsbeispiel 1 ; Datenstruktur: (Wert Meter kg sec Ampere) (defun u* (a b) "Multiplikation im mksa-System" (cons (* (car a) (car b)) (mapcar '+ (cdr a) (cdr b)))) (defun u+ (a b) "Addition im mksa-System, nur bei gleichen Einheiten möglich" (if (equal (cdr a) (cdr b)) (cons (+ (car a) (car b)) (cdr a)) (error "Inkompatible Einheiten")))
474
Common Lisp
.l
17
24.235294
43
0.632743
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
746124c6d750d912b5370c63115491c871e0a71df0960b8df5be44447984a2c1
38,043
[ -1 ]
38,044
pi.lsp
macropeter_Lisp-Trials/pi.lsp
;;;SICP 1.3.1 (defun pireihe (i n) (if (> i n) 0 (+ (* (/ 1.0 i) (/ 1.0 (+ i 2))) (pireihe (+ i 4) n)))) (defun faltung (fkt i n) (if (> i n) 0 (+ (funcall fkt i) (faltung fkt (1+ i) n)))) (defun pi-term (n) (* (/ 1.0 n) (/ 1.0 (+ n 2)))) (defun falt-summe (fkt i naechst n) (if (> i n) 0 (+ (funcall fkt i) (falt-summe fkt (funcall naechst i) naechst n)))) ;; (falt-summe #'pi-term 1 (lambda (x)(+ x 4)) 10) (defun pi-summe (a b) (flet ((pi-next (x) (+ x 4.0)) (pi-term1 (x) (* (/ 1.0 x) (/ 1.0 (+ 2 x))))) (falt-summe #'pi-term1 a #'pi-next b))) ;; (* 8 (pi-summe 1 50))
653
Common Lisp
.l
27
20.222222
51
0.470779
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
badd15cb60c9bdb732b38c364b56d850401e699333fc4998b37adca7476ebcc9
38,044
[ -1 ]
38,045
Bakermap0.lsp
macropeter_Lisp-Trials/Bakermap0.lsp
;;;eindimensionale Bakermap ;;;dynamisches System, wie von Gisin vorgeschlagen ;; April 2021 ; zeigt, dass CLisp standardmäßig mit 32bit-Realzahlen rechnet ;; rechnet man mit Brüchen, kann man die ganze Kapazität von Lisp präsentieren (defun mod1 (x) "modulo 1 rechnen" (multiple-value-bind (ganz teil) (floor x) teil)) (defun baker (x) "einfachste Bäckertrafo: ausrollen und falten" (if (< x 0.5) (* 2 x) (- 2 (* 2 x)))) (defun baker1 (i x) "iterierte Bäckertrafo" (when (<= i 100) (princ i) (princ ": ") (princ x) (terpri) (if (>= x 0.5) (baker1 (1+ i) (- (* 2 x) 1)) (baker1 (1+ i) (* 2 x))))) ;Ausgabe mit format (defun bakerf (i maxz x) (when (<= i maxz) (format t "~d : ~f~%" i x) (if (>= x 0.5) (bakerf (1+ i) maxz (- (* 2 x) 1)) (bakerf (1+ i) maxz (* 2 x))))) (defun bakerprocess (startx maxz) "Iterierte Bäckertrafo, am besten mit einem Bruch starten" (labels ((baker (i x) (when (<= i maxz) (format t "~d , ~f~%" i x) (if (>= x 0.5) (baker (1+ i) (- (* 2 x) 1)) (baker (1+ i) (* 2 x)))) ) ) (baker 1 startx) ;zufällige double-float-Zahl: (random 0.34d0) oder einen Bruch ) ) (defun bakerziffer (i maxz x) (let ((xx (floor (* 2 x)))) ; nur für die Ausgabe der Ziffer 0 oder 1 (when (<= i maxz) (format t "~d : ~f :~T ~d~%" i x xx) (if (>= x 0.5) (bakerziffer (1+ i) maxz (- (* 2 x) 1)) (bakerziffer (1+ i) maxz (* 2 x))))))
1,545
Common Lisp
.l
63
20.174603
83
0.554795
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
f4c360747a2ede6536800a8567bcf9b1d6f137fd6dce4754df773d6f0c441299
38,045
[ -1 ]
38,046
cd.lsp
macropeter_Lisp-Trials/cd.lsp
;CD-Datenbankprojekt nach Seibel "PCL" ;Dezember 2010 (defvar *db* nil) (defun make-cd (titel artist rating ripped) (list :titel titel :artist artist :rating rating :ripped ripped)) (defun add-record (cd) (push cd *db*)) (defun dump-db () (dolist (cd *db*) (format t "~{~a:~10t~a~%~}~%" cd))) ;kryptische Stringdirektiven (defun prompt-read (prompt) (format *query-io* "~a:" prompt) ;*query-io*: globale Variable für den terminal input stream (force-output *query-io*) ;Problem mi newline bei manchen Dialekten (read-line *query-io*)) (defun prompt-for-cd () (make-cd (prompt-read "Titel:") (prompt-read "Künstler:") (prompt-read "Rating:") (y-or-n-p "gerippt"))) ;gibt j/n aus, erwartet aber y für ja (defun add-cds () (loop (add-record (prompt-for-cd)) ;quasi repeat-Schleife (if (not (y-or-n-p "Noch eine CD eingeben?")) (return)) )) (defun save-db (filename) (with-open-file (out filename :direction :output :if-exists :supersede) (with-standard-io-syntax (print *db* out)))) (defun load-db (filename) (with-open-file (in filename) (with-standard-io-syntax (setf *db* (read in)))))
1,264
Common Lisp
.l
37
28.891892
94
0.622626
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
ad0d9f164c1d6d1e344af40aac0675c83a321eb9d871d733b21a871b6f768d94
38,046
[ -1 ]
38,047
insert.lsp
macropeter_Lisp-Trials/insert.lsp
;InsertionSort ;vgl die Haskellvariante ;Mai 2010 (defun sorthelper (glist x) ;x in eine geordnete Liste einfügen (cond ((null glist)(list x)) (T (let ((k (car glist))) (cond ((< x k)(cons x glist)) (T (cons k (sorthelper (cdr glist) x)))) ) ) ) ) (defun sorthelper2 (liste hliste) ;Elems von einer Liste (liste) (cond ((null liste) hliste) ;in eine andere (hliste) einordnen (T (let ((neuliste (sorthelper hliste (car liste)))) (sorthelper2 (cdr liste) neuliste))) ) ) (defun insort (LL) (sorthelper2 LL nil) ;die geordnete Liste ist zunächst leer )
751
Common Lisp
.l
22
25.136364
73
0.528276
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
a41c79bbfac132a23b2ae7ca2a4dfd4b7241146b64270c2a0d0e4b94d59509d4
38,047
[ -1 ]
38,048
poker.lsp
macropeter_Lisp-Trials/poker.lsp
; Pokertest für Zufallszahlen (0,1-Liste) ; Dez 2010 (defun hpoker (x liste nr) (if (null liste) nr (if (= x (car liste)) (hpoker (car liste) (cdr liste) nr) (hpoker (car liste) (cdr liste) (+ nr 1))))) (defun pokertest (liste) (if (not (null liste)) (hpoker (car liste) (cdr liste) 0))) ; 01-Liste der Länge nr erstellen (defun liste01 (nr) (let (ll) (dotimes (i nr) (setf ll (cons (random 2) ll))) ll)) ; n-mal 01Listen von der Länge 50 erstellen und auswerten (defun runtest (n) "n-mal 01Listen von der Länge 50 erstellen und auswerten" (let (erglist) (dotimes (i n) (setf erglist (cons (pokertest (liste01 50)) erglist))) (format t "Anzahl der Läufe:") erglist))
857
Common Lisp
.l
22
29.318182
82
0.550847
macropeter/Lisp-Trials
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
eb0c42ae27015b2b2c945089db75e4e8a084e16e4768af3ee7de1b4f29ff9886
38,048
[ -1 ]
38,081
Unificacion.lsp
ceskmcfran_USALprojects-Unification-Algorithm/Unificacion.lsp
;Ejemplo de como ejecutar: ; ; (setf clausula2 '(p (A) (B))) ; (setf clausula1 '(p (? x) (? x))) ; (setf solucion (unificar clausula1 clausula2)) ; (print '(La solucion es)) ; (print solucion) (setf false 'False) (setf nada 'Nada) (defun isAtom(var) (cond ((atom var) T) ((eq (first var) '?) T) (T NIL) ) ) (defun isVariable(var) (cond ((and (listp var) (= (length var) 2) (eq (first var) '?)) T) (T NIL) ) ) (defun insertAfter (lst index newEle) (push newEle (cdr (nthcdr index lst))) ) (defun build(tem1 tem2) (prog (result var1 var2) (setf var1 tem1) (setf var2 tem2) (setf result (list var1 var2)) (insertAfter result 0 '/) (setf result (rest (list T result))) (return result) ) ) (defun aplicar(z lista) (prog (myZ result numElementos elemento) (setf myZ z) (when (eq myZ nada) (return lista) ) (setf result lista) (loop for elemento in myZ do (setf sustituyente (first elemento)) (setf sustituido (nth 2 elemento)) (setf result (subst sustituyente sustituido result :test #'equal)) ) (return result) ) ) (defun componer(s1 s2) (prog (myS1 myS2 elementoS1 elementoS2 numeradorMyS1 denominadorMyS1 numeradorMyS2 denominadorMyS2 exist) (setf myS1 s1) (setf myS2 s2) (when (eq myS1 nada) (return myS2) ) (when (eq myS2 nada) (return myS1) ) (loop for elementoS2 in myS2 do (setf numeradorMyS2 (first elementoS2)) (setf denominadorMyS2 (nth 2 elementoS2)) (setf exist '0) (loop for elementoS1 in myS1 do (setf numeradorMyS1 (first elementoS1)) (setf denominadorMyS1 (nth 2 elementoS1)) (if (equalp denominadorMyS2 denominadorMyS1) (setf exist '1) ) ) (when (eq exist '0) (loop for elementoS1 in myS1 do (setf myS1 (subst numeradorMyS2 denominadorMyS2 myS1 :test #'equal)) ) (insertAfter myS1 (- (length myS1) 1) elementoS2) ) ) (return myS1) ) ) (defun unificar(h1 h2) (prog (e1 e2 temp result b f1 f2 t1 t2 g1 g2 z1 z2) (setf e1 h1) (setf e2 h2) (when (or (isAtom e1) (isAtom e2)) (unless (isAtom e1) (print 'Intercambio) (setf temp e1) (setf e1 e2) (setf e2 temp) ) (when (equalp e1 e2) (return nada) ) (when (isVariable e1) (when (member e1 e2) (return false) ) (setf b (build e2 e1)) (return b) ) (when (isVariable e2) (setf b (buid e1 e2)) (return b) ) (return false) ) (setf f1 (first e1)) (setf t1 (rest e1)) (setf f2 (first e2)) (setf t2 (rest e2)) (setf z1 (unificar f1 f2)) (when (eq z1 false) (print '(z1 vale false)) (return false) ) (setf g1 (aplicar z1 t1)) (setf g2 (aplicar z1 t2)) (setf z2 (unificar g1 g2)) (when (eq z2 false) (return false) ) (return (componer z1 z2)) ) ) (setf clausula2 '(p (A) (B))) (setf clausula1 '(p (? x) (? y))) (setf solucion (unificar clausula1 clausula2)) (print '(La solucion es)) (print solucion)
3,885
Common Lisp
.l
129
19.51938
114
0.492003
ceskmcfran/USALprojects-Unification-Algorithm
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
db07af2b67ed3ce72fdffccdf8a843c45baac5411e618e13861128e23fdd3ef0
38,081
[ -1 ]
38,098
listagem_de_funcoes.lsp
tictackode_My-firsts-Commom-Lisp-Codes/listagem_de_funcoes.lsp
; funcoes matematicas (defun inc(x) (+ x 1)) (defun dec(x) (- x 1)) (defun media(x y) (/ (+ x y) 2)) ; nao esta funcionando corrigir! (defun par-impar(x) (if(evenp(x)) (format_t "par") (format_t "impar"))) ; funcao one-of para selecionar um item aleatorio em uma lista (excelente!!) (defun one-of(set) (list (random-elt set))) (defun random-elt(choices) (elt choices (random (length choices)))) ; definicoes de listas para auxiliar o estudo (setf frutas '(pera uva maçã banana goiaba melancia laranja limão maracujá)) (setf verbos-eu '(gosto quero odeio amo)) (setf tempo '(de_manhã de_tarde de_noite de_madrugada)) (defun fala()(list(one-of verbos-eu)(one-of frutas)(one-of tempo)))
710
Common Lisp
.l
19
35
76
0.710682
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
839d5c985885ad0eb24e526ce1928b8afd7a39afc52b8f9bb02620aa155fc48e
38,098
[ -1 ]
38,099
japones.lsp
tictackode_My-firsts-Commom-Lisp-Codes/japones.lsp
(defun one-of(set) (list (random-elt set))) (defun random-elt(choices) (elt choices (random (length choices)))) (defun is-in-list(x)(cond((member x lista)(format t"esta na lista")) ( t ( format t"não esta na lista")))) (setq lista '( aai amor kotoba palavra hohoemi sorriso bakudan bomba watashi eu)) (setq dic '( (aai amor) (kotoba palavra) (hohoemi sorriso) (bakudan bomba) (watashi eu))) (defun rand(x)(one-of x)) ; convenção - palavra japonesa primeiro (defun rand-j(x)(first(first (rand x)))) (defun rand-p(x)(last(first (rand x)))) (defun rand2(x)(setq aux (one-of x))(list (first(first aux)) (first(last(first aux))))) (defun quest-j(x)(setq questao (rand2 dic)) (format t"Traduza: ~S " (first questao)) (setq resp (read)) (cond((eql resp (first(last questao)))(format t"Correto!")) (t (format t"Incorreto!")))) (defun quest-p(x)(setq questao (rand2 dic)) (format t"Traduza: ~S " (first (last questao))) (setq resp (read)) (cond((eql resp (first questao))(format t"Correto!")) (t (format t"Incorreto!")))) ; retorna t or nil (defun q2-j(x)(setq questao (rand2 dic)) (format t"Traduza: ~S " (first questao)) (setq resp (read)) (cond((eql resp (first(last questao))) t ) (t nil))) ; conta o numero de acertos de 5 perguntas (defun quiz-5j(x)(setq cont 0)(cond((eql (q2-j dic) t)(setq cont (+ cont 1)))) (cond((eql (q2-j dic) t)(setq cont (+ cont 1)))) (cond((eql (q2-j dic) t)(setq cont (+ cont 1)))) (cond((eql (q2-j dic) t)(setq cont (+ cont 1)))) (cond((eql (q2-j dic) t)(setq cont (+ cont 1)))) (format t"~D acertos!" cont)) ; recebe como parametro a palavra e a traducao se usar ' se nao usar avalia a exp. ex.: (first lista) (defun non-rand-quest(x)(setq questao x) (format t"Traduza: ~S " (first questao)) (setq resp (read)) (cond((eql resp (first(last questao))) t ) (t nil)))
2,317
Common Lisp
.l
42
41.809524
105
0.522527
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
716da464b51641179589fba369dce671d801d3046e11b46928c113711861b512
38,099
[ -1 ]
38,100
Lista2PythonBrasil.lsp~
tictackode_My-firsts-Commom-Lisp-Codes/Lista2PythonBrasil.lsp~
; Lista 2 Python Brasil - Regson ;1-Faça um Programa que peça dois números e imprima o maior deles. (defun maior()(format t"Digite um numero: ")(setq n1 (read)) (format t"Digite outro numero: ")(setq n2 (read)) (cond ((> n1 n2)(format t"O maior numero é ~F~%" n1)) ((< n1 n2)(format t" O maior numero é ~F~%" n2)))) ;2-Faça um Programa que peça um valor e mostre na tela se o valor é positivo ou negativo. (defun pos-neg()(format t"Digite um numero: ")(setq num (read)) (cond ((minusp num)(format t"O número é negativo!")) ((plusp num)(format t"O número é positivo!")) ((zerop num)(format t"o número é zero!")))) ;3-Faça um Programa que verifique se uma letra digitada é "F" ou "M". Conforme a letra escrever: ; F - Feminino, M - Masculino, Sexo Inválido. (defun sexo()(format t" Digite m para masculino e f para feminino: ")(setq sexo (read)) (cond ((eql sexo 'm)(format t"Masculino")) ((eql sexo 'f)(format t"Feminino")) (t (format t"Sexo Inválido!")))) ;4-Faça um Programa que verifique se uma letra digitada é vogal ou consoante. (defun vogal-consoante()(format t"Digite uma letra: ")(setq letra (read)) (cond ((eql letra 'a)(format t"Vogal!")) ((eql letra 'e)(format t"Vogal!")) ((eql letra 'i)(format t"Vogal!")) ((eql letra 'o)(format t"Vogal!")) ((eql letra 'u)(format t"Vogal!")) ( t (format t"Consoante!")))) ;5-Faça um programa para a leitura de duas notas parciais de um aluno. ;O programa deve calcular a média alcançada por aluno e apresentar: ;A mensagem "Aprovado", se a média alcançada for maior ou igual a sete; ;A mensagem "Reprovado", se a média for menor do que sete; ;A mensagem "Aprovado com Distinção", se a média for igual a dez. (defun notas()(format t"Digite a primeita nota: ")(setq nota1 (read)) (format t"Digite a segunda nota: ")(setq nota2 (read))(setq final (/ (+ nota1 nota2) 2)) (cond ((AND (>= final 7) (< final 10)) (format t"Aprovado!")) ((< final 7)(format t"Reprovado!")) ((> final 10)(format t"Notas inválidas: Valores acima de 10")) ((equalp final 10)(format t"Aprovado com Distinção!")))) ;6-Faça um Programa que leia três números e mostre o maior deles. (defun maior()(format t"Digite um numero:")(setq n1 (read)) (format t"Digite outro numero:")(setq n2 (read)) (format t"Digite o terceiro numero:")(setq n3 (read)) (cond ((AND (> n1 n2) (> n1 n3))(format t"~F~% é o maior" n1)) ((AND (> n2 n1) (> n2 n3))(format t"~F~% é o maior" n2)) ( t (format t"~F~% é o maior" n3)))) ;7-Faça um Programa que leia três números e mostre o maior e o menor deles. ; funcoes auxiliares (defun maior(n1 n2 n3)(cond ((AND (> n1 n2) (> n1 n3))(format t"~F é o maior ~% " n1)) ((AND (> n2 n1) (> n2 n3))(format t"~F é o maior~%" n2)) ( t (format t"~F é o maior~%" n3)))) (defun menor(n1 n2 n3)(cond ((AND (< n1 n2) (< n1 n3))(format t"~F é o menor~%" n1)) ((AND (< n2 n1) (< n2 n3))(format t"~F é o menor~%" n2)) ( t (format t"~F é o menor~%" n3)))) ; função completa (defun maior-menor()(format t"Digite um numero:")(setq n1 (read)) (format t"Digite outro numero:")(setq n2 (read)) (format t"Digite o terceiro numero:")(setq n3 (read)) (maior n1 n2 n3)(menor n1 n2 n3)) ;8-Faça um programa que pergunte o preço de três produtos e informe qual produto você deve comprar, ; sabendo que a decisão é sempre pelo mais barato. ;funções auxiliares (defun leitura()(format t"Digite o nome do primeiro produto:")(setq n1 (read)) (format t"Digite o preço:")(setq p1 (read))(setq produto1 (list n1 p1)) (format t"Digite o nome do segundo produto:")(setq n2 (read)) (format t"Digite o preço:")(setq p2 (read))(setq produto2 (list n2 p2)) (format t"Digite o nome do primeiro produto:")(setq n3 (read)) (format t"Digite o preço:")(setq p3 (read))(setq produto3 (list n3 p3))) (defun menor(n1 n2 n3)(cond ((AND (< n1 n2) (< n1 n3)) n1) ((AND (< n2 n1) (< n2 n3)) n2) ( t n3))) (defun produto-barato(x)(cond ((equalp x (first(last produto1)))(format t"Voce deve comprar ~S~%" (first produto1))) ((equalp x (first(last produto2)))(format t"Voce deve comprar ~S~%" (first produto2))) ((equalp x (first(last produto3)))(format t"Voce deve comprar ~S~%" (first produto3))))) ;exercicio completo (defun ex08()(leitura)(produto-barato (menor (first(last produto1)) (first(last produto2)) (first(last produto3))))) ;9-Faça um Programa que leia três números e mostre-os em ordem decrescente. ;funções auxiliares (defun menor(n1 n2 n3)(cond ((AND (< n1 n2) (< n1 n3)) n1) ((AND (< n2 n1) (< n2 n3)) n2) ( t n3))) (defun maior(n1 n2 n3)(cond ((AND (> n1 n2) (> n1 n3)) n1) ((AND (> n2 n1) (> n2 n3)) n2) ( t n3))) ;exercicio completo (defun decrescente()(format t"Digite um numero:")(setq n1 (read)) (format t"Digite outro numero:")(setq n2 (read)) (format t"Digite o terceiro numero:")(setq n3 (read)) (setq num-maior (maior n1 n2 n3))(setq num-menor (menor n1 n2 n3)) (cond ((AND (NOT (equalp num-maior n1)) (NOT (equalp num-menor n1)))(setq meio n1)) ((AND (NOT (equalp num-maior n2)) (NOT (equalp num-menor n2)))(setq meio n2)) ( t (setq meio n3))) (list num-maior meio num-menor)) ;10-Faça um Programa que pergunte em que turno você estuda. Peça para digitar M-matutino ou V-Vespertino ; ou N- Noturno. Imprima a mensagem "Bom Dia!", "Boa Tarde!" ou "Boa Noite!" ou "Valor Inválido!", conforme o caso. (defun saudacao()(format t"Digite o periodo em que vc estuda: M-matutino, V-vespertino, N-noturno") (setq periodo (read)) (cond ((eql periodo 'm)(format t"Bom dia!")) ((eql periodo 'v)(format t"Boa tarde!")) ((eql periodo 'n)(format t"Boa noite!")) ( t (format t"Valor invalido!")))) ;11-As Organizações Tabajara resolveram dar um aumento de salário aos seus colaboradores e ;lhe contraram para desenvolver o programa que calculará os reajustes. ;Faça um programa que recebe o salário de um colaborador e o reajuste segundo o seguinte ;critério, baseado no salário atual: ;salários até R$ 280,00 (incluindo) : aumento de 20% ;salários entre R$ 280,00 e R$ 700,00 : aumento de 15% ;salários entre R$ 700,00 e R$ 1500,00 : aumento de 10% ;salários de R$ 1500,00 em diante : aumento de 5% Após o aumento ser realizado, informe na tela: ;o salário antes do reajuste; ;o percentual de aumento aplicado; ;o valor do aumento; ;o novo salário, após o aumento. (defun salario()(format t"Digite o salario do colaborador: ")(setq salario (read)) (cond (( AND (< salario 280) (equalp salario 280))(setq percentual '20%)(setq aumento (* salario 0.2)) (setq novo-sal (+ salario aumento))) (( AND (> salario 280) (< salario 700)) (setq percentual '15%)(setq aumento (* salario 0.15)) (setq novo-sal (+ salario aumento))) (( AND (> salario 700) (< salario 1500)) (setq percentual '10%)(setq aumento (* salario 0.1)) (setq novo-sal (+ salario aumento))) ((OR (> salario 1500) (equalp salario 1500))(setq percentual '5%)(setq aumento (* salario 0.05)) (setq novo-sal (+ salario aumento)))) (format t"salário antes do reajuste ~F~%" salario) (format t"O percentual de aumento aplicado ~S~%" percentual) (format t"O valor do aumento ~F~%" aumento) (format t"Novo salario ~F~%" novo-sal)) ;12- ;13-Faça um Programa que leia um número e exiba o dia correspondente da semana. ;(1-Domingo, 2- Segunda, etc.), se digitar outro valor deve aparecer valor inválido. (defun semana()(format t"Digite um numero: ")(setq num (read)) (setq semana '(Domingo Segunda Terça Quarta Quinta Sexta Sabado)) (cond ((equalp num 1)(first semana)) ((equalp num 2)(second semana)) ((equalp num 3)(third semana)) ((equalp num 4)(fourth semana)) ((equalp num 5)(fifth semana)) ((equalp num 6)(sixth semana)) ((equalp num 7)(first(last semana))) (t (format t"Valor inválido!")))) ;14-Faça um programa que lê as duas notas parciais obtidas por um aluno numa disciplina ; ao longo de um semestre, e calcule a sua média. A atribuição de conceitos obedece à tabela abaixo: ; Média de Aproveitamento Conceito ; Entre 9.0 e 10.0 A ; Entre 7.5 e 9.0 B ; Entre 6.0 e 7.5 C ; Entre 4.0 e 6.0 D ; Entre 4.0 e zero E (defun media()(format t"Digite a primeira nota: ")(setq nota1 (read)) (format t"Digite a segunda nota: ")(setq nota2 (read)) (setq media (/ (+ nota1 nota2) 2.0)) (cond ((AND (> media 8.99) (< media 10.01))(format t"A Aprovado!")) ((AND (> media 7.49) (< media 9.0))(format t"B Aprovado!")) ((AND (> media 5.99) (< media 7.5))(format t"C Aprovado!")) ((AND (> media 3.99) (< media 6.0))(format t"D Reprovado!")) ((AND (> media 0) (< media 4.0))(format t"E Reprovado!")) (t (format t"Nota inválida!")))) ;15-Faça um Programa que peça os 3 lados de um triângulo. O programa deverá informar se ; os valores podem ser um triângulo. Indique, caso os lados formem um triângulo, ; se o mesmo é: equilátero, isósceles ou escaleno. ;Três lados formam um triângulo quando a soma de quaisquer dois lados for maior que o terceiro; ;Triângulo Equilátero: três lados iguais; ;Triângulo Isósceles: quaisquer dois lados iguais; ;Triângulo Escaleno: três lados diferentes; (defun leitura()(format t"Digite o primeiro lado: ")(setq a (read)) (format t"Digite o segundo lado: ")(setq b (read)) (format t"Digite o primeiro lado: ")(setq c (read))) ; esse tem erro (defun teste-triangulo()(leitura)(cond ((OR (> (+ a b) c) (> ( + b c) a) (> ( + a c) b)) ((setq isT 's)(format t"Forma triangulo!")) (t ((setq isT 'n)(format t"Não forma triangulo!"))))))
11,425
Common Lisp
.l
167
54.45509
119
0.559872
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
acdcada61bbc4356fd6825157a650d464916ea1cd521d9ed0bae11ff9d4c052d
38,100
[ -1 ]
38,101
Lista2PythonBrasil~
tictackode_My-firsts-Commom-Lisp-Codes/Lista2PythonBrasil~
; Lista 2 Python Brasil - Regson ;1-Faça um Programa que peça dois números e imprima o maior deles. (defun maior()(format t"Digite um numero: ")(setq n1 (read)) (format t"Digite outro numero: ")(setq n2 (read)) (cond ((> n1 n2)(format t"O maior numero é ~F~%" n1)) ((< n1 n2)(format t" O maior numero é ~F~%" n2)))) ;2-Faça um Programa que peça um valor e mostre na tela se o valor é positivo ou negativo. (defun pos-neg()(format t"Digite um numero: ")(setq num (read)) (cond ((minus num)(format t"O número é negativo!"))(format t"O numero é positivo")))
623
Common Lisp
.l
9
60.777778
99
0.620295
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
ead36d8fa5d5f786e9e337ee4fffc4580cb12962ceac52c2aab39844725cb7be
38,101
[ -1 ]
38,102
lista_de_exercicios.lsp~
tictackode_My-firsts-Commom-Lisp-Codes/lista_de_exercicios.lsp~
(defun head(x)(car x)) (defun tail(x)(last x)) (defun enigma (x) ( cond ((endp x) t) (t (and (first x) (enigma (rest x)) ))))
151
Common Lisp
.l
6
20
30
0.503497
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
62b10331d5d7204793f55ad5e31013e19ac162e0d8235697deca5c7d795bb425
38,102
[ -1 ]
38,103
Baralho~
tictackode_My-firsts-Commom-Lisp-Codes/Baralho~
(defun one-of(set) (list (random-elt set))) (defun random-elt(choices) (elt choices (random (length choices)))) (defvar valor '(dois tres quatro cinco seis sete oito nome dez valete dama rei as)) (defvar naipe '(paus copas espadas ouro)) (defun card()(list(one-of valor)(one-of naipe)))
294
Common Lisp
.l
7
40
83
0.728873
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
63dd9513312313a137bcef7a07c940ff9baec1348efe8c41847e73aa2f518175
38,103
[ -1 ]
38,104
Lista2PythonBrasil.lsp
tictackode_My-firsts-Commom-Lisp-Codes/Lista2PythonBrasil.lsp
; Lista 2 Python Brasil - Regson ;1-Faça um Programa que peça dois números e imprima o maior deles. (defun maior()(format t"Digite um numero: ")(setq n1 (read)) (format t"Digite outro numero: ")(setq n2 (read)) (cond ((> n1 n2)(format t"O maior numero é ~F~%" n1)) ((< n1 n2)(format t" O maior numero é ~F~%" n2)))) ;2-Faça um Programa que peça um valor e mostre na tela se o valor é positivo ou negativo. (defun pos-neg()(format t"Digite um numero: ")(setq num (read)) (cond ((minusp num)(format t"O número é negativo!")) ((plusp num)(format t"O número é positivo!")) ((zerop num)(format t"o número é zero!")))) ;3-Faça um Programa que verifique se uma letra digitada é "F" ou "M". Conforme a letra escrever: ; F - Feminino, M - Masculino, Sexo Inválido. (defun sexo()(format t" Digite m para masculino e f para feminino: ")(setq sexo (read)) (cond ((eql sexo 'm)(format t"Masculino")) ((eql sexo 'f)(format t"Feminino")) (t (format t"Sexo Inválido!")))) ;4-Faça um Programa que verifique se uma letra digitada é vogal ou consoante. (defun vogal-consoante()(format t"Digite uma letra: ")(setq letra (read)) (cond ((eql letra 'a)(format t"Vogal!")) ((eql letra 'e)(format t"Vogal!")) ((eql letra 'i)(format t"Vogal!")) ((eql letra 'o)(format t"Vogal!")) ((eql letra 'u)(format t"Vogal!")) ( t (format t"Consoante!")))) ;5-Faça um programa para a leitura de duas notas parciais de um aluno. ;O programa deve calcular a média alcançada por aluno e apresentar: ;A mensagem "Aprovado", se a média alcançada for maior ou igual a sete; ;A mensagem "Reprovado", se a média for menor do que sete; ;A mensagem "Aprovado com Distinção", se a média for igual a dez. (defun notas()(format t"Digite a primeita nota: ")(setq nota1 (read)) (format t"Digite a segunda nota: ")(setq nota2 (read))(setq final (/ (+ nota1 nota2) 2)) (cond ((AND (>= final 7) (< final 10)) (format t"Aprovado!")) ((< final 7)(format t"Reprovado!")) ((> final 10)(format t"Notas inválidas: Valores acima de 10")) ((equalp final 10)(format t"Aprovado com Distinção!")))) ;6-Faça um Programa que leia três números e mostre o maior deles. (defun maior()(format t"Digite um numero:")(setq n1 (read)) (format t"Digite outro numero:")(setq n2 (read)) (format t"Digite o terceiro numero:")(setq n3 (read)) (cond ((AND (> n1 n2) (> n1 n3))(format t"~F~% é o maior" n1)) ((AND (> n2 n1) (> n2 n3))(format t"~F~% é o maior" n2)) ( t (format t"~F~% é o maior" n3)))) ;7-Faça um Programa que leia três números e mostre o maior e o menor deles. ; funcoes auxiliares (defun maior(n1 n2 n3)(cond ((AND (> n1 n2) (> n1 n3))(format t"~F é o maior ~% " n1)) ((AND (> n2 n1) (> n2 n3))(format t"~F é o maior~%" n2)) ( t (format t"~F é o maior~%" n3)))) (defun menor(n1 n2 n3)(cond ((AND (< n1 n2) (< n1 n3))(format t"~F é o menor~%" n1)) ((AND (< n2 n1) (< n2 n3))(format t"~F é o menor~%" n2)) ( t (format t"~F é o menor~%" n3)))) ; função completa (defun maior-menor()(format t"Digite um numero:")(setq n1 (read)) (format t"Digite outro numero:")(setq n2 (read)) (format t"Digite o terceiro numero:")(setq n3 (read)) (maior n1 n2 n3)(menor n1 n2 n3)) ;8-Faça um programa que pergunte o preço de três produtos e informe qual produto você deve comprar, ; sabendo que a decisão é sempre pelo mais barato. ;funções auxiliares (defun leitura()(format t"Digite o nome do primeiro produto:")(setq n1 (read)) (format t"Digite o preço:")(setq p1 (read))(setq produto1 (list n1 p1)) (format t"Digite o nome do segundo produto:")(setq n2 (read)) (format t"Digite o preço:")(setq p2 (read))(setq produto2 (list n2 p2)) (format t"Digite o nome do primeiro produto:")(setq n3 (read)) (format t"Digite o preço:")(setq p3 (read))(setq produto3 (list n3 p3))) (defun menor(n1 n2 n3)(cond ((AND (< n1 n2) (< n1 n3)) n1) ((AND (< n2 n1) (< n2 n3)) n2) ( t n3))) (defun produto-barato(x)(cond ((equalp x (first(last produto1)))(format t"Voce deve comprar ~S~%" (first produto1))) ((equalp x (first(last produto2)))(format t"Voce deve comprar ~S~%" (first produto2))) ((equalp x (first(last produto3)))(format t"Voce deve comprar ~S~%" (first produto3))))) ;exercicio completo (defun ex08()(leitura)(produto-barato (menor (first(last produto1)) (first(last produto2)) (first(last produto3))))) ;9-Faça um Programa que leia três números e mostre-os em ordem decrescente. ;funções auxiliares (defun menor(n1 n2 n3)(cond ((AND (< n1 n2) (< n1 n3)) n1) ((AND (< n2 n1) (< n2 n3)) n2) ( t n3))) (defun maior(n1 n2 n3)(cond ((AND (> n1 n2) (> n1 n3)) n1) ((AND (> n2 n1) (> n2 n3)) n2) ( t n3))) ;exercicio completo (defun decrescente()(format t"Digite um numero:")(setq n1 (read)) (format t"Digite outro numero:")(setq n2 (read)) (format t"Digite o terceiro numero:")(setq n3 (read)) (setq num-maior (maior n1 n2 n3))(setq num-menor (menor n1 n2 n3)) (cond ((AND (NOT (equalp num-maior n1)) (NOT (equalp num-menor n1)))(setq meio n1)) ((AND (NOT (equalp num-maior n2)) (NOT (equalp num-menor n2)))(setq meio n2)) ( t (setq meio n3))) (list num-maior meio num-menor)) ;10-Faça um Programa que pergunte em que turno você estuda. Peça para digitar M-matutino ou V-Vespertino ; ou N- Noturno. Imprima a mensagem "Bom Dia!", "Boa Tarde!" ou "Boa Noite!" ou "Valor Inválido!", conforme o caso. (defun saudacao()(format t"Digite o periodo em que vc estuda: M-matutino, V-vespertino, N-noturno") (setq periodo (read)) (cond ((eql periodo 'm)(format t"Bom dia!")) ((eql periodo 'v)(format t"Boa tarde!")) ((eql periodo 'n)(format t"Boa noite!")) ( t (format t"Valor invalido!")))) ;11-As Organizações Tabajara resolveram dar um aumento de salário aos seus colaboradores e ;lhe contraram para desenvolver o programa que calculará os reajustes. ;Faça um programa que recebe o salário de um colaborador e o reajuste segundo o seguinte ;critério, baseado no salário atual: ;salários até R$ 280,00 (incluindo) : aumento de 20% ;salários entre R$ 280,00 e R$ 700,00 : aumento de 15% ;salários entre R$ 700,00 e R$ 1500,00 : aumento de 10% ;salários de R$ 1500,00 em diante : aumento de 5% Após o aumento ser realizado, informe na tela: ;o salário antes do reajuste; ;o percentual de aumento aplicado; ;o valor do aumento; ;o novo salário, após o aumento. (defun salario()(format t"Digite o salario do colaborador: ")(setq salario (read)) (cond (( AND (< salario 280) (equalp salario 280))(setq percentual '20%)(setq aumento (* salario 0.2)) (setq novo-sal (+ salario aumento))) (( AND (> salario 280) (< salario 700)) (setq percentual '15%)(setq aumento (* salario 0.15)) (setq novo-sal (+ salario aumento))) (( AND (> salario 700) (< salario 1500)) (setq percentual '10%)(setq aumento (* salario 0.1)) (setq novo-sal (+ salario aumento))) ((OR (> salario 1500) (equalp salario 1500))(setq percentual '5%)(setq aumento (* salario 0.05)) (setq novo-sal (+ salario aumento)))) (format t"salário antes do reajuste ~F~%" salario) (format t"O percentual de aumento aplicado ~S~%" percentual) (format t"O valor do aumento ~F~%" aumento) (format t"Novo salario ~F~%" novo-sal)) ;12- ;13-Faça um Programa que leia um número e exiba o dia correspondente da semana. ;(1-Domingo, 2- Segunda, etc.), se digitar outro valor deve aparecer valor inválido. (defun semana()(format t"Digite um numero: ")(setq num (read)) (setq semana '(Domingo Segunda Terça Quarta Quinta Sexta Sabado)) (cond ((equalp num 1)(first semana)) ((equalp num 2)(second semana)) ((equalp num 3)(third semana)) ((equalp num 4)(fourth semana)) ((equalp num 5)(fifth semana)) ((equalp num 6)(sixth semana)) ((equalp num 7)(first(last semana))) (t (format t"Valor inválido!")))) ;14-Faça um programa que lê as duas notas parciais obtidas por um aluno numa disciplina ; ao longo de um semestre, e calcule a sua média. A atribuição de conceitos obedece à tabela abaixo: ; Média de Aproveitamento Conceito ; Entre 9.0 e 10.0 A ; Entre 7.5 e 9.0 B ; Entre 6.0 e 7.5 C ; Entre 4.0 e 6.0 D ; Entre 4.0 e zero E (defun media()(format t"Digite a primeira nota: ")(setq nota1 (read)) (format t"Digite a segunda nota: ")(setq nota2 (read)) (setq media (/ (+ nota1 nota2) 2.0)) (cond ((AND (> media 8.99) (< media 10.01))(format t"A Aprovado!")) ((AND (> media 7.49) (< media 9.0))(format t"B Aprovado!")) ((AND (> media 5.99) (< media 7.5))(format t"C Aprovado!")) ((AND (> media 3.99) (< media 6.0))(format t"D Reprovado!")) ((AND (> media 0) (< media 4.0))(format t"E Reprovado!")) (t (format t"Nota inválida!")))) ;15-Faça um Programa que peça os 3 lados de um triângulo. O programa deverá informar se ; os valores podem ser um triângulo. Indique, caso os lados formem um triângulo, ; se o mesmo é: equilátero, isósceles ou escaleno. ;Três lados formam um triângulo quando a soma de quaisquer dois lados for maior que o terceiro; ;Triângulo Equilátero: três lados iguais; ;Triângulo Isósceles: quaisquer dois lados iguais; ;Triângulo Escaleno: três lados diferentes; ;!!!nao esta pronto (defun leitura()(format t"Digite o primeiro lado: ")(setq a (read)) (format t"Digite o segundo lado: ")(setq b (read)) (format t"Digite o primeiro lado: ")(setq c (read))) ; esse tem erro (defun teste-triangulo()(leitura)(cond ((AND (> (+ a b) c) (> ( + b c) a) (> ( + a c) b)) (format t"Forma triangulo!")) (t (format t"Não forma triangulo!")))) ;16-Faça um programa que calcule as raízes de uma equação do segundo grau, na forma ax2 + bx + c. ; O programa deverá pedir os valores de a, b e c e fazer as consistências, informando ao usuário ;nas seguintes situações: ;Se o usuário informar o valor de A igual a zero, a equação não é do segundo grau e o programa não ; deve fazer pedir os demais valores, sendo encerrado; ;Se o delta calculado for negativo, a equação não possui raizes reais. Informe ao usuário e encerre o programa; ;Se o delta calculado for igual a zero a equação possui apenas uma raiz real; informe-a ao usuário; ;Se o delta for positivo, a equação possui duas raiz reais; informe-as ao usuário; (defun equacao()(format t"Equacao do 2o grau: Digite o valor de a: ")(setq a (read)) (format t"Digite o valor de b: ")(setq b (read)) (format t"Digite o valor de c: ")(setq c (read)) (cond ((equalp a 0)(format t"Não é equacao do segundo grau!"))))
12,371
Common Lisp
.l
180
55.5
119
0.572768
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
68b121cc819409c352e029f53946fe7e505000875eceac009e0870fd687b5bbd
38,104
[ -1 ]
38,105
lista1PythonBrasil.lsp~
tictackode_My-firsts-Commom-Lisp-Codes/lista1PythonBrasil.lsp~
; 1- (defun ola-mundo()(format t"Olá Mundo!")) ; 2- (defun numero()(format t "Digite um numero")(setq n (read))(format t"O numero digitado foi ~D~%"n)) ;3-Faça um Programa que peça dois números e imprima a soma. (defun soma()(format t"Digite o primeiro numero: ")(setq num1 (read)) (format t"Digite o segundo numero: ")(setq num2 (read)) (format t"A soma é ~D~%" (+ num1 num2))) ; 4-Faça um Programa que peça as 4 notas bimestrais e mostre a média. (defun media()(format t"Digite a primeira nota: ")(setq n1 (read)) (format t"Digite a segunda nota: ")(setq n2 (read)) (format t"Digite a terceira nota ")(setq n3 (read)) (format t"Digite a quarta nota: ")(setq n4 (read)) (format t"A media e ~F~%" ( / (+ n1 n2 n3 n4) 4.0))) ; 5-Faça um Programa que converta metros para centímetros. (defun m-to-cm()(format t"Digite uma medida em metros:")(setq x (read)) (format t"~F~% centimetros" ( * x 100))) ;6-Faça um Programa que peça o raio de um círculo, calcule e mostre sua área. (defun circulo()(format t"Insira o raio do circulo: ")(setq r (read)) (format t"A area é ~F~%" (* 3.14 ( * r r)))) ;7-Faça um Programa que calcule a área de um quadrado, em seguida mostre o dobro desta área para o usuário. (defun quadrado()(format t"Digite o lado do quadrado")(setq lado (read)) (format t"O dobro da area é ~F~%" (* 2 (* lado lado)))) ;8-Faça um Programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês. Calcule e mostre o total do seu salário no referido mês. (defun salario()(format t"Quanto ganha por hora?")(setq por-hora (read)) (format t"Quantas horas foram trabalhadas no mes?")(setq horas-mes (read)) (format t"Salario do mes ~F~%" (* por-hora horas-mes))) ;9-Faça um Programa que peça a temperatura em graus Farenheit, transforme e mostre a temperatura em graus Celsius. ;C = (5 * (F-32) / 9). (defun far-to-c()(format t" Digite a temperatura em farenheit")(setq f (read)) (format t"Em Celsius: ~F~%" (/ (* 5 (- f 32)) 9))) ; 10-Faça um Programa que peça a temperatura em graus Celsius, transforme e mostre em graus Farenheit. conferir a equacao!! (defun c-to-far()(format t" Digite a temperatura em Celsius:")(setq c (read)) (format t"Em Fahrenheit: ~F~%" (+ (/ (* 9 c) 5) 32))) ; 11-Faça um Programa que peça 2 números inteiros e um número real. Calcule e mostre: ;o produto do dobro do primeiro com metade do segundo . ;a soma do triplo do primeiro com o terceiro. ;o terceiro elevado ao cubo.O terceiro elevado ao cubo (defun ex11()(format t"Digite o primeiro numero inteiro: ")(setq int1 (read)) (format t"Digite o segundo numero inteiro: ")(setq int2 (read)) (format t"Digite o numero real: ")(setq real (read)) (format t"Produto do dobro do primeiro com a metade do segundo ~F~%" (* (* 2 int1) (/ int2 2))) (format t"Soma do triplo do primeiro com o terceiro ~F~%" ( + (* 3 int1) real)) (format t "O terceiro elevado ao cubo ~F~%" (* real real real))) ;12-Tendo como dados de entrada a altura de uma pessoa, construa um algoritmo que calcule seu peso ideal, ; usando a seguinte fórmula: (72.7*altura) - 58 (defun peso-ideal()(format t"Digite a altura: ")(setq altura (read)) (format t"Peso ideal ~F~%" (- (* 72.7 altura) 58))) ;13-Tendo como dados de entrada a altura e o sexo de uma pessoa, construa um algoritmo que calcule seu peso ideal, ; utilizando as seguintes fórmulas: ;Para homens: (72.7*h) - 58 ;Para mulheres: (62.1*h) - 44.7 (h = altura) ;Peça o peso da pessoa e informe se ela está dentro, acima ou abaixo do peso. (defun peso-ideal2()(format t"Digite a altura: ")(setq altura (read)) (format t"Digite m para masculino e f para feminino")(setq sexo (read))(format t"Digite o peso")(setq peso (read)) (cond ((eql sexo 'm)(cond ((> peso (- (* 72.7 altura) 58))(format t"Acima do peso!")) ((< peso (- (* 72.2 altura) 58))(format t"Dentro do peso!")))) ((eql sexo 'f)(cond ((> peso (- (* 62.1 altura) 44.7))(format t"Acima do peso!")) ((< peso (- (* 62.1 altura) 44.7))(format t"Dentro do peso!")))))) ;14-João Papo-de-Pescador, homem de bem, comprou um microcomputador para controlar o rendimento diário de seu trabalho. ; Toda vez que ele traz um peso de peixes maior que o estabelecido pelo regulamento de pesca do estado de São Paulo ; (50 quilos) deve pagar uma multa de R$ 4,00 por quilo excedente. João precisa que você faça um programa que leia ; a variável peso (peso de peixes) e verifique se há excesso. Se houver, gravar na variável excesso e na variável multa ; o valor da multa que João deverá pagar. Caso contrário mostrar tais variáveis com o conteúdo ZERO. (defun peixes()(format t"Digite o peso dos peixes: ")(setq peso (read)) (cond ((< peso 50)(format t" Não há multa!")) ((> peso 50)(format t"Valor da multa: ~F~%" (* (- peso 50) 4.00))))) ; 15-Faça um Programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês. Calcule e mostre o total do seu salário no referido mês, sabendo-se que são descontados 11% para o Imposto de Renda, 8% para o INSS e 5% para o sindicato, faça um programa que nos dê: ;salário bruto. ;quanto pagou ao INSS. ;quanto pagou ao sindicato. ;o salário líquido. ;calcule os descontos e o salário líquido, conforme a tabela abaixo: ;+ Salário Bruto : R$ ;- IR (11%) : R$ ;- INSS (8%) : R$ ;- Sindicato ( 5%) : R$ ;= Salário Liquido : R$ ;Obs.: Salário Bruto - Descontos = Salário Líquido. (defun salario()(format t"Quanto ganha por hora?")(setq por-hora (read)) (format t"Digite o numero de horas trabalhadas: ")(setq num-horas (read)) (setq bruto (* por-hora num-horas))(setq IR ( * bruto 0.11)) (setq INSS (* bruto 0.08))(setq sindicato (* bruto 0.05)) (format t"+ Salário Bruto : R$ ~F~%" bruto) (format t"- IR (11%) : R$ ~F~%" IR) (format t"- INSS (8%) : R$ ~F~%" INSS) (format t"- Sindicato (5%) : R$ ~F~%" sindicato) (format t"=Salário Liquido : R$ ~F~%" (- bruto (+ IR INSS sindicato)))) ; 16-Faça um programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área a ser pintada. Considere que a cobertura da tinta é de 1 litro para cada 3 metros quadrados e que a tinta é vendida em latas de 18 litros, que custam R$ 80,00. Informe ao usuário a quantidades de latas de tinta a serem compradas e o preço total. (defun loja-tintas()(format t"Informe o tamanho da da area a ser pintada:" ) (setq area (read))(setq num-latas (/ (/ area 3.0) 18.0)) (format t"Numero de latas de tintas ~F~%" num-latas) (format t"Preço total: ~F~%" (* num-latas 80.00))) ; 17-Faça um Programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área a ser pintada. Considere que a cobertura da tinta é de 1 litro para cada 6 metros quadrados e que a tinta é vendida em latas de 18 litros, que custam R$ 80,00 ou em galões de 3,6 litros, que custam R$ 25,00. Informe ao usuário as quantidades de tinta a serem compradas e os respectivos preços em 3 situações: comprar apenas latas de 18 litros; comprar apenas galões de 3,6 litros; misturar latas e galões, de forma que o preço seja o menor. Acrescente 10% de folga e sempre arredonde os valores para cima, isto é, considere latas cheias. ; nao esta pronto! ; funcoes auxiliares (defun calcula-latas(area)(setq num-latas (/ (/ area 6.0) 18.0)) (format t"Situação 1-Numero de latas de tintas ~F~%" num-latas)) (defun calcula-galoes(area)(setq num-galoes (/ (/ area 6.0) 3.6)) (format t"Situaçao 2- Numero de galões: ~F~%" num-galoes)) (defun loja-tintas2()(format t"Informe o tamanho da da area a ser pintada:" ) (setq area (read))(calcula-latas area)(calcula-galoes area)) ;18-Faça um programa que peça o tamanho de um arquivo para download (em MB) e a velocidade de um link de Internet (em Mbps), calcule e informe o tempo aproximado de download do arquivo usando este link (em minutos). (defun download-speed()(format t"Digite o tamanho do arquivo em MB : ")(setq tam (read)) (format t"Digite a velocidade da conexão em Mbps: ")(setq vel (read)) (format t" O tempo estimado é de ~F~% minutos" (/ ( / tam (/ vel 10)) 60 )))
8,797
Common Lisp
.l
110
71.3
354
0.643592
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
96e9d891c8b8893b003a3b5a4789620607b746ea7a50e5b5e6814e97bf911a5f
38,105
[ -1 ]
38,106
lista_de_exercicios.lsp
tictackode_My-firsts-Commom-Lisp-Codes/lista_de_exercicios.lsp
(defun head(x)(car x)) (defun tail(x)(last x)) ; o exercicio é: o que faz esta funcao? (defun enigma (x) ( cond ((endp x) t) (t (and (first x) (enigma (rest x)) )))) ;LISTP takes any Lisp data-item, and returns T if it is a list, and NIL otherwise. ;ENDP which takes a list, and returns T if the list is empty, NIL otherwise. (This function is also known as NULL.) Note that (endp nil) return;s T : nil is an empty set. ;NUMBERP tests to see if it is a number. ;SYMBOLP tests to see if it is a symbol. ;There are quite a few number predicates. A few of them are: ;ZEROP : is it zero ;PLUSP and MINUSP : is it positive or negative ;EVENP and ODDP : is it even or odd
691
Common Lisp
.l
15
43.4
170
0.692878
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
455d499314ae6a85fc1212f470f64336b17ea588e7428da59eef73873a17e31a
38,106
[ -1 ]
38,107
media-alunos
tictackode_My-firsts-Commom-Lisp-Codes/media-alunos
(defun media (x y)(/ (+ x y) 2.0)) (defun resultado(x y) (if (>= (media x y) 5)(format t"aprovado") (format t"reprovado"))) (defun notas (progn (x y) (format t"digite a primeira nota") (setq x (read)) (format t"digite a segunda nota") (setq y (read))) (resultado x y))
286
Common Lisp
.l
9
29
51
0.618182
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
a1456335587ba220ae55df31b911b775d48d8af3eb3583f5af9712378ebf3d02
38,107
[ -1 ]
38,108
lista3PythonBrasil.lsp
tictackode_My-firsts-Commom-Lisp-Codes/lista3PythonBrasil.lsp
;1-Faça um programa que peça uma nota, entre zero e dez. ;Mostre uma mensagem caso o valor seja inválido e continue ;pedindo até que o usuário informe um valor válido. ; exemplo loop (loop for x in '(a b c d e f) do (print x)) ((setq aux nil)(setq nota -1)(while aux ((read nota)(cond((> nota 0) and (< nota 10.1)) (setq aux t)))))
343
Common Lisp
.l
5
65.8
104
0.690909
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
4b57226a2d9bbdb6f45ce1675b6781d4e7a613267488ff53f2497db6b00e2244
38,108
[ -1 ]
38,109
guessGame#1.lsp
tictackode_My-firsts-Commom-Lisp-Codes/guessGame#1.lsp
(setf num 80) (defun try(x)(cond(< x num) ("numero muito grande") (> x num) ("numero muito pequeno") (= x num) ("Certa Resposta!")))
170
Common Lisp
.l
4
32.25
52
0.49697
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
03fbdfb90347ad683508568c8b0dc80f9a18dffe865ef37f0ec4d120c23e0aad
38,109
[ -1 ]
38,110
GradeFit.lsp
tictackode_My-firsts-Commom-Lisp-Codes/GradeFit.lsp
; recebe uma nota inicial e uma nova nota, calcula a proporçãoo e a aplica ; a uma lista de notas, gerando como saída a lista de notas na nova ; proporção (defun %P(x y) (/ (/ (* y 100.0) x) 100.0)) (defun auxGradeFit(p list )(mapcar '(lambda(x)(* x p)) list)) (defun gradeFit(n1 n2 lista)(auxGradeFit (%P n1 n2) lista))
344
Common Lisp
.l
6
52.666667
74
0.693038
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
751f8bc92401a9a5a6d135a7ab8125fefdf3012042553bea58e11406c6050c40
38,110
[ -1 ]
38,111
GuessGame.lsp
tictackode_My-firsts-Commom-Lisp-Codes/GuessGame.lsp
(setf max 99) (setf min 1) (defun sorteia() (+ (random max) 1))
67
Common Lisp
.l
3
20.333333
36
0.639344
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
46c663baada2bea2804523a1146cfde679cc902ea57624665fbff4dc0dd7ef42
38,111
[ -1 ]
38,112
japones.lsp~
tictackode_My-firsts-Commom-Lisp-Codes/japones.lsp~
(defun one-of(set) (list (random-elt set))) (defun random-elt(choices) (elt choices (random (length choices)))) (defun is-in-list(x)(cond((member x lista)(format t"esta na lista")) ( t ( format t"não esta na lista")))) (setq lista '( aai amor kotoba palavra hohoemi sorriso bakudan bomba watashi eu)) (setq dic '( (aai amor) (kotoba palavra) (hohoemi sorriso) (bakudan bomba) (watashi eu))) (defun rand(x)(one-of x)) ; convenção - palavra japonesa primeiro (defun rand-j(x)(first(first (rand x)))) (defun rand-p(x)(last(first (rand x)))) (defun rand2(x)(setq aux (one-of x))(list (first(first aux)) (first(last(first aux))))) (defun quest-j(x)(setq questao (rand2 dic)) (format t"Traduza: ~S " (first questao)) (format t" debug: ~S" (first(last questao)))(setq resp (read)) (cond((eql resp (first(last questao)))(format t"Correto!")) (t (format t"Incorreto!")))) (defun quest-p(x)(setq questao (rand2 dic)) (format t"Traduza: ~S " (first (last questao))) (setq resp (read)) (cond((eql resp (first questao))(format t"Correto!")) (t (format t"Incorreto!"))))
1,257
Common Lisp
.l
23
45.043478
89
0.585306
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
9f31298da5c484509b201c2cf6d674ee6b477502b706e8ac730e8b3379177bbf
38,112
[ -1 ]
38,113
media_aluno.lsp~
tictackode_My-firsts-Commom-Lisp-Codes/media_aluno.lsp~
(defun nota()(print"Digite a primeira nota: ")(setf nota1 (read)) (print"Digite a segunda nota: ")(setf nota2 (read)) (list '(a media é )(/ (+ nota1 nota2) 2.0)))
169
Common Lisp
.l
3
53.333333
66
0.628743
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
1f45bb9f46535684275434e171f825820f6c31ae031ee0b71ad47089abd6752d
38,113
[ -1 ]
38,114
Baralho.lsp
tictackode_My-firsts-Commom-Lisp-Codes/Baralho.lsp
(defun one-of(set) (list (random-elt set))) (defun random-elt(choices) (elt choices (random (length choices)))) (setf valor '(dois tres quatro cinco seis sete oito nome dez valete dama rei as)) (setf naipe '(paus copas espadas ouro)) (defun card()(list(one-of valor)(one-of naipe))) (defun poker-hand()(list(one-of valor)(one-of naipe)(one-of valor)(one-of naipe)(one-of valor)(one-of naipe) (one-of valor)(one-of naipe)(one-of valor)(one-of naipe)))
459
Common Lisp
.l
8
55.375
167
0.718121
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
219065e6f01829f542dddec86d9b77d0c77e8c0f10275a04e17bba10bd176b44
38,114
[ -1 ]
38,115
media_aluno.lsp
tictackode_My-firsts-Commom-Lisp-Codes/media_aluno.lsp
(defun media(x y)(/ (+ x y) 2.0)) (defun nota()(print"Digite a primeira nota: ")(setf nota1 (read)) (print"Digite a segunda nota: ")(setf nota2 (read)) (list '(a media é )(/ (+ nota1 nota2) 2.0))) (defun le-dados-aluno()(print"Nome: ") (setf nome (read))(print"Nota 1: ")(setf nota1 (read)) (print"Nota 2: ")(setf nota2 (read))(format t"Aluno: ~S~% Nota 1: ~D~% Nota 2: ~D~% " nome nota1 nota2 ) (print "Media: ")(media nota1 nota2))
454
Common Lisp
.l
8
53.25
107
0.605856
tictackode/My-firsts-Commom-Lisp-Codes
0
0
0
GPL-3.0
9/19/2024, 11:44:33 AM (Europe/Amsterdam)
08f7d5176580cf4dd3099efe2e6b65402ec17b16faff9fa69b82b454a843d095
38,115
[ -1 ]