Copy inference steps in a scm file for easier experiment

;; PLN inference carried over the background knowledge to overwrite
;; the truth value of the MOSES model based solely on the dataset.

;; Load MOSES model
(load "moses-model.scm")

;; Load the background knowledge
(load "background-knowledge.scm")

;; Load the PLN configuration for this demo
(load "pln-config.scm")

;; Apply the inference rules using the pattern matcher. This only
;; contains the executions, see the README.md for the explanations and
;; the expected results.

;; (1)
(for-each (lambda (i) (cog-bind implication-partial-instantiation-rule))
          (iota 2))

;; (2)
(cog-bind implication-lambda-distribution-rule)

;; (3)
(cog-bind and-lambda-distribution-rule)

;; (4)
(cog-bind lambda-grounded-construction-rule)

;; (5)
(cog-bind implication-construction-rule)

;; ;; (6)
;; (cog-bind implication-implicant-distribution-rule)

;; ;; (7)
;; (cog-bind implication-and-lambda-factorization-rule)

;; (8)
(cog-bind deduction-implication-rule)

;; (9)
;;
;; Actually the previous deduction step took care of that too, so no
;; need to run it
;;
;; (cog-bind deduction-implication-rule)

;; (10)
(cog-bind implication-full-instantiation-rule)

;; (11)
(cog-bind equivalence-to-double-implication-rule)

;; (12)
(cog-bind deduction-implication-rule)

;; (13)
(cog-bind deduction-implication-rule)

;; (14)
(cog-bind deduction-implication-rule)

;; ;; (15)
;; (cog-bind deduction-implication-rule)

;; ;; (16)


<div id="$HolderID" class="field<% if extraClass %> $extraClass<% end_if %>">

        $Field
        $Title

    <% if $Message %>$Message<% end_if %>
    <% if $Description %>$Description<% end_if %>


Add programming contest templates for Scheme

(define (main-function)
  (letrec ((main-loop (lambda ()
                        (let ((a (read)) (b (read)))
                          (if (or (eof-object? a) (eof-object? b))
                            #f
                            (begin (display a)
                                   (display a)
                                   <+CURSOR+>
                                   (main-loop)))))))
    (main-loop)))

(main-function)


Add note about gimp batch color correct script

; Applies auto-white balance to all images in current folder matching glob pattern
  ; based on: https://gist.github.com/dbuscombe-usgs/6085758
  ; To install save file in gimp scripts folder
  ; To find the scripts folder, open gimp and go to edit->preferences->folders->scripts
  ; cd to folder with images and run
  ; time gimp -i -b '(batch-color-correct "*.JPG")' -b '(gimp-quit 0)'
  ; changing *.JPG to image glob type
  ; script takes approx 6 seconds per image on Ryzen 3500u, ubuntu 20.10

  (define (batch-color-correct pattern
                )
  (let* ((filelist (cadr (file-glob pattern 1))))
   (while (not (null? filelist))
      (let* ((filename (car filelist))
          (image (car (gimp-file-load RUN-NONINTERACTIVE
                        filename filename)))
          (drawable (car (gimp-image-get-active-layer image))))
       (gimp-levels-stretch drawable)
       (gimp-file-save RUN-NONINTERACTIVE
               image drawable filename filename)
       (gimp-image-delete image))
      (set! filelist (cdr filelist)))))


<% include GoogleJavaScript %>
<div id="$GoogleMapID" <% if ShowInlineMapDivStyle %>style="width:{$Width}; height: {$Height};"
<% end_if %><% if AdditionalCssClasses %> class="$AdditionalCssClasses"<% end_if %>>
</div>

Move JavaScript for priming map where it is not broken by using partial caching

<% include GoogleJavaScript %>
<div id="$GoogleMapID" <% if ShowInlineMapDivStyle %>style="width:{$Width}; height: {$Height};"
<% end_if %><% if AdditionalCssClasses %> class="$AdditionalCssClasses"<% end_if %>>
</div>
<script type="text/javascript">
$JavaScript
</script>


; Usage: guile pgcd.scm

(define (pgcd a b)
    (display "a=") (display a) (display " - b=") (display b) (newline)
    (cond ((> b a) (pgcd b a))
        ((zero? b) a)
        (else (pgcd b (modulo a b)))))

(display (pgcd 80 120))
(newline)


(load "tests/run-tests.scm")
;; (display (+ 1 201))
;; (newline)

;; (display (modulo 109 11))
;; (newline)

;; (display (> 11 9))
;; (newline)

;; (display (/ 123 7))
;; (newline)

(run-test (+ 1 201))
(run-test (modulo 109 11))
(run-test (> 11 9))
(run-test (/ 123 7))


<a class="gridfield-button-link btn btn-secondary font-icon-explore-addons" href="$Link.ATT" target="_blank">
    $Caption.XML
</a>

FIX "Explore addons" text now correctly aligns with its icon


	<% if Introduction %>

$Title

			<% if Introduction %>

$Introduction

			<% end_if %>

	<% else %>

$Title

	<% end_if %>

	<% include DocumentationVersions %>

	<% if VersionWarning %>
		<% include DocumentationVersion_warning %>
	<% end_if %>

	<% include DocumentationTableContents %>

	<% loop Children %>

$Title

	<% end_loop %>

	<% include DocumentationNextPrevious %>

Fix formatting for folder pages.

	<% if Introduction %>

$Title

			<% if Introduction %>

$Introduction

			<% end_if %>

		<% if Breadcrumbs %>
			<% include DocumentationBreadcrumbs %>
		<% end_if %>
	<% else %>
		<% if Breadcrumbs %>
			<% include DocumentationBreadcrumbs %>
		<% end_if %>

$Title

	<% end_if %>

	<% include DocumentationVersions %>

	<% if VersionWarning %>
		<% include DocumentationVersion_warning %>
	<% end_if %>

	<% include DocumentationTableContents %>

	<% if Children %>

				<% loop Children %>

$Title

						<% if Summary %>
$Summary
<% end_if %>

				<% end_loop %>

	<% end_if %>

	<% include DocumentationNextPrevious %>


ADD - Sitesprocket theme template for changing your user profile

						Projects & Tickets

<% _t('SSP.EDITPROFILE','Edit profile') %>

<% _t('SSP.LOGOUT','Logout') %>

<% _t('SSP.PROFILEFORM','Edit your profile') %>

				$ProfileForm


; Usage: guile factorielle_naive.scm

(define (fact n)
    (if (zero? n)
        1
        (* n (fact (- n 1)))))

(display (fact 10))
(newline)


<% include GoogleJavaScript %>

<% if $Caption %>
$Caption
<% end_if %>

Move JavaScript to a template that can be rendered at the end of the page


    <% if not $TreeIsFiltered %>
        <%-- Change to data-pjax-target="Content-PageList" to enable in-edit listview --%>
        <a class="page-view-link btn btn-secondary btn--icon-sm btn--no-text font-icon-tree"
            href="$LinkTreeView.ATT"
            data-view="treeview"
            data-pjax-target="$PJAXTarget.ATT"
            title="<%t SilverStripe\CMS\Controllers\CMSPagesController.TreeView 'Tree View' %>"
        >
    <% end_if %>
    <a class="page-view-link btn btn-secondary btn--icon-sm btn--no-text font-icon-list"
        href="$LinkListView.ATT"
        data-view="listview"
        data-pjax-target="$PJAXTarget.ATT"
        title="<%t SilverStripe\CMS\Controllers\CMSPagesController.ListView 'List View' %>"
    >

FIX no button view type toggle when searching pages

    <% if not $TreeIsFiltered %>
        <%-- Change to data-pjax-target="Content-PageList" to enable in-edit listview --%>
        <a class="page-view-link btn btn-secondary btn--icon-sm btn--no-text font-icon-tree"
            href="$LinkTreeView.ATT"
            data-view="treeview"
            data-pjax-target="$PJAXTarget.ATT"
            title="<%t SilverStripe\CMS\Controllers\CMSPagesController.TreeView 'Tree View' %>"
        >

        <a class="page-view-link btn btn-secondary btn--icon-sm btn--no-text font-icon-list"
            href="$LinkListView.ATT"
            data-view="listview"
            data-pjax-target="$PJAXTarget.ATT"
            title="<%t SilverStripe\CMS\Controllers\CMSPagesController.ListView 'List View' %>"
        >
    <% end_if %>


                <% if $HeroVideo %>

                <% else_if $HeroImage %>

                <% else %>

                <% end_if %>

$Title

$DueDate.Format('eeee MMMM d, yyyy')

Fix broken publication link on Hail Page


$SearchForm

$Heading

<% if ProjectResults %>

			<% include ProjectResults %>

<% else %>
	<% _t('SSPAdmin.NOPROJECTS','There are no projects that meet your criteria') %>
<% end_if %>

FIX - Added
 class and tag to style no results message


Add form template support for kube forms

<% if IncludeFormTag %>
<form $addExtraClass('forms').AttributesHTML>
<% end_if %>
	<% if Message %>

$Message

	<% else %>

	<% end_if %>

	<fieldset>
		<% if Legend %><legend>$Legend</legend><% end_if %>
		<% loop Fields %>
			$FieldHolder
		<% end_loop %>

	</fieldset>

	<% if Actions %>

		<% loop Actions %>
			$addExtraClass('btn').Field
		<% end_loop %>

	<% end_if %>
<% if IncludeFormTag %>
</form>
<% end_if %>


<%-- Args: $Title, $Link, $DesktopImage [, $MobileImage [, $TabletImage ]] --%>

	<% if $DesktopImage.exists %>

	<% end_if %>
	<% if $MobileImage.exists %>

	<% end_if %>
	<% if $TabletImage.exists %>

	<% end_if %>

Fix a CSS class name collision.


;; Vaadin support for Scheme
(import "com.vaadin.ui.*")
(import "com.vaadin.data.util.*")
(import "com.github.mjvesa.spil.VaadinUtil")

(define (inner-doto target ops)
  (if (eq? ops '())
      `(,target)
      (cons `(,(car (car ops)) ,target ,(car (cdr (car ops))))
	                   (inner-doto target (cdr ops)))))

(define-macro (doto target ops)
  (cons 'begin (inner-doto target ops)))

(define (list-to-array lst)
  (let ((col (ArrayList.)))
    (begin
      (for-each (lambda (item) (.add col item)) lst)
      (.toArray col))))

(define (create-container-with-fields lst)
  (let ((cnt (IndexedContainer.)))
    (begin
      (for-each (lambda (str)
                  (.addContainerProperty cnt str java.lang.String.class "")) lst)
       cnt)))

(define (set-prop item prop field)
 (.setValue (.getItemProperty item prop) (.getValue field)))

(define (set-props-from-fields item props)
  (if (null? item)
    '()
    (begin
      (set-prop item (car (car props)) (car (cdr (car props))))
      (set-props-from-fields item (cdr props)))))

(define (add-components cont components)
  (for-each (lambda (c) (.addComponent cont c))
	    components))

Create in-memory-crud from address book example

;; Vaadin support for Scheme
(import "com.vaadin.ui.*")
(import "com.vaadin.data.util.*")
(import "com.github.mjvesa.spil.VaadinUtil")

(define (inner-doto target ops)
  (if (eq? ops '())
      `(,target)
      (cons `(,(car (car ops)) ,target ,(car (cdr (car ops))))
	                   (inner-doto target (cdr ops)))))

(define-macro (doto target ops)
  (cons 'begin (inner-doto target ops)))

(define (list-to-array lst)
  (let ((col (ArrayList.)))
    (begin
      (for-each (lambda (item) (.add col item)) lst)
      (.toArray col))))

(define (create-container-with-fields lst)
  (let ((cnt (IndexedContainer.)))
    (begin
      (for-each (lambda (str)
                  (.addContainerProperty cnt str java.lang.String.class "")) lst)
       cnt)))

(define (set-prop item prop field)
 (.setValue (.getItemProperty item prop) (.getValue field)))

(define (set-props-from-fields item props)
  (if (null? item)
    '()
    (begin
      (set-prop item (car (car props)) (car (cdr (car props))))
      (set-props-from-fields item (cdr props)))))

(define (add-components cont components)
  (for-each (lambda (c) (.addComponent cont c))
	    components)
  cont)


<% if $Images %>

<% loop $Images %>
			<% with $SetHeight($Top.ThumbnailHeight) %><% end_with %><% end_loop %>

<% end_if %>

Allow to handle complex captions on Fotorama

<% if $Images %>

<% loop $Images %>
			<a href="$SetHeight($Top.Height).Link"<% if $Content %>
			   data-summary="$Content.FirstSentence"
			   data-caption="$Content.ATT"<% else %>
			   data-caption="$Title.ATT"<% end_if %>
			   data-full="$Link.ATT"><% with $SetHeight($Top.ThumbnailHeight) %><% end_with %><% end_loop %>

<% end_if %>


<% _t('SSP.ORDERDETAILS','Order details') %>

<% control SelectedOptions %>

		<% control Option %>
			$Title ($Price.Nice)

		<% end_control %>
		<% if Attachments %>
			<% control Attachments %>
				 [$Name <% _t('SSP.ATTACHED','attached') %>]

			<% end_control %>
		<% end_if %>

<% end_control %>
<% if Notes %>

<% _t('SSP.NOTES','Notes') %>

$Notes

<% end_if %>

Total paid by credit card: $TotalCost.Nice

FIX - changed HTML for better styling options

<% _t('SSP.ORDERDETAILS','Initial Order details') %>

	<% control SelectedOptions %>

			<% control Option %>

$Title ($Price.Nice)

			<% end_control %>
			<% if Attachments %>

				<% control Attachments %>

$Name <% _t('SSP.ATTACHED','attached') %> (download)

				<% end_control %>

			<% end_if %>

	<% end_control %>

Total paid by credit card: $TotalCost.Nice

	<% if Notes %>

<% _t('SSP.NOTES','Notes') %>

$Notes

	<% end_if %>


;
; Simple crisp deduction example
;
; 1. Launch guile under this directory (see examples/guile/README.md
; for prerequisite if you haven't already)
;
; $ guile
;
; 2. The load this file
;
; scheme@(guile-user)> (load-from-path "simple-deduction.scm")
;
; 3. Scroll to the bottom, and run some of the commented-out examples.

(use-modules (opencog))
(use-modules (opencog rule-engine))

(load-from-path "utilities.scm")
(load-from-path "av-tv.scm")

; Load URE configuration (add the current file dir so it can be loaded
; from anywhere)
(add-to-load-path (dirname (current-filename)))
(load-from-path "simple-deduction-config.scm")

; Define knowledge base
(define A (ConceptNode "A"))
(define B (ConceptNode "B"))
(define C (ConceptNode "C"))
(define AB (ImplicationLink (stv 1 1) A B))
(define BC (ImplicationLink (stv 1 1) B C))

; (cog-fc AB (ConceptNode "crisp-rule-base"))

; Expected output should be
; TODO

Add comment about rule-engine example output

;
; Simple crisp deduction example
;
; 1. Launch guile under this directory (see examples/guile/README.md
; for prerequisite if you haven't already)
;
; $ guile
;
; 2. The load this file
;
; scheme@(guile-user)> (load-from-path "simple-deduction.scm")
;
; 3. Scroll to the bottom, and run some of the commented-out examples.

(use-modules (opencog))
(use-modules (opencog rule-engine))

(load-from-path "utilities.scm")
(load-from-path "av-tv.scm")

; Load URE configuration (add the current file dir so it can be loaded
; from anywhere)
(add-to-load-path (dirname (current-filename)))
(load-from-path "simple-deduction-config.scm")

; Define knowledge base
(define A (ConceptNode "A"))
(define B (ConceptNode "B"))
(define C (ConceptNode "C"))
(define AB (ImplicationLink (stv 1 1) A B))
(define BC (ImplicationLink (stv 1 1) B C))

; (cog-fc AB (ConceptNode "crisp-rule-base"))

; Expected output should be something like
;; $1 = (ListLink
;;    (ImplicationLink (stv 1 0.99999982)
;;       (ConceptNode "A")
;;       (ConceptNode "C")
;;    )
;; )


;; Copyright (c) 2012-2015 Bruno Deferrari.  All rights reserved.
;; BSD 3-Clause License: http://opensource.org/licenses/BSD-3-Clause

(define-library (shen runner)
  (import (chibi)
          (shen init))
  (begin
    (define (main arguments)
      (cond ((= 1 (length arguments)) (shen.shen))
            (else (shen.quiet-load (cadr arguments)))))))

Remove unnecessary dependence on chibi module

;; Copyright (c) 2012-2015 Bruno Deferrari.  All rights reserved.
;; BSD 3-Clause License: http://opensource.org/licenses/BSD-3-Clause

(define-library (shen runner)
  (import (scheme base)
          (shen init))
  (begin
    (define (main arguments)
      (cond ((= 1 (length arguments)) (shen.shen))
            (else (shen.quiet-load (cadr arguments)))))))


<% if DownloadJS %>
<% if DelayLoadMapFunction %>
console.log('delay map loading');
<% else %>
<script src="//maps.google.com/maps/api/js?sensor=false&hl=$Lang" type="text/javascript"></script>
<script type="text/javascript" src="/mappable/javascript/google/maputil.js"></script>

<script type="text/javascript">google.maps.event.addDomListener(window, 'load', loadedGoogleMapsAPI);</script>
<% end_if %>

<script type="text/javascript">
// map details are stored here and used to invoke maps in the loadedGoogleMapsAPI function
var mappableMaps = [];
</script>
<!-- end of common js -->

<% end_if %>
<% if UseClusterer %>
  <script src="$ClustererLibraryPath" type="text/javascript"></script>

 <% end_if %>

<script type="text/javascript">
// mapping of google_map_N to an array of markers

<% if DownloadJS %>
 var infoWindows = [];
 var gmarkers = [];
 var mapLayers = [];
 var mapLines = [];
<% end_if %>
    registerMap('$GoogleMapID', $LatLngCentre, $Zoom, $MinLat,$MinLng,$MaxLat,$MaxLng, $MapType, $MapMarkers, $Lines,$KmlFiles, $JsonMapStyles, $EnableAutomaticCenterZoom, $UseClusterer);
</script>

 <div id="$GoogleMapID" <% if ShowInlineMapDivStyle %>style="width:{$Width}; height: {$Height};"<% end_if %><% if AdditionalCssClasses %> class="$AdditionalCssClasses"<% end_if %>>
</div>

Refactor to extract the downloading of JavaScript as a centralised entity (needed for Google Street View and Google Maps)

<% include GoogleJavaScript %>

<script type="text/javascript">
// mapping of google_map_N to an array of markers
<% if DownloadJS %>
 var infoWindows = [];
 var gmarkers = [];
 var mapLayers = [];
 var mapLines = [];
<% end_if %>
    registerMap('$GoogleMapID', $LatLngCentre, $Zoom, $MinLat,$MinLng,$MaxLat,$MaxLng, $MapType, $MapMarkers, $Lines,$KmlFiles, $JsonMapStyles, $EnableAutomaticCenterZoom, $UseClusterer);
</script>
 <div id="$GoogleMapID" <% if ShowInlineMapDivStyle %>style="width:{$Width}; height: {$Height};"<% end_if %><% if AdditionalCssClasses %> class="$AdditionalCssClasses"<% end_if %>>
</div>


#! /usr/bin/env scheme-script
;; -*- scheme -*-
(import
  (chezscheme)
  (harlan compile-opts)
  (harlan driver)
  (elegant-weapons print-c)
  (harlan compiler)
  (util system) ;; HARLAND
  )

;; This could be set from the env var HARLAND, or based on the
;; directory in which this script resides.  Using the latter:
(HARLAND (path-parent (car (command-line))))

;; Converts foo/bar.kfc to bar
(define (output-filename input)
  (let ((base (path-last (path-root input))))
    (if (make-shared-object)
        (string-append base ".so")
        base)))

(define print-compile-harlan
  (lambda (filename)
    (let-values (((input testspec) (read-source filename)))
      (if (assq 'iterate testspec)
          (error 'harlanc
                 "Test iteration is not supported. Use run-tests.scm instead.")
          (let* ((c-expr (compile-harlan input))
                 (c-code (format-c c-expr)))
            (if (verbose) (printf c-code))
            (g++-compile-stdin c-code (output-filename filename)))))))

;; (trace-pass
;;  'remove-nested-kernels
;;  'optimize-lift-lets)

(let ((args (parse-args (cdr (command-line)))))
  (unless (null? args)
    (let ((filename (car args)))
      (print-compile-harlan filename))))

Use Harlan's format-c instead of vanilla elegant-weapons format-c.

#! /usr/bin/env scheme-script
;; -*- scheme -*-
(import
  (chezscheme)
  (harlan compile-opts)
  (harlan driver)
  (harlan backend print-c)
  (harlan compiler)
  (util system) ;; HARLAND
  )

;; This could be set from the env var HARLAND, or based on the
;; directory in which this script resides.  Using the latter:
(HARLAND (path-parent (car (command-line))))

;; Converts foo/bar.kfc to bar
(define (output-filename input)
  (let ((base (path-last (path-root input))))
    (if (make-shared-object)
        (string-append base ".so")
        base)))

(define print-compile-harlan
  (lambda (filename)
    (let-values (((input testspec) (read-source filename)))
      (if (assq 'iterate testspec)
          (error 'harlanc
                 "Test iteration is not supported. Use run-tests.scm instead.")
          (let* ((c-expr (compile-harlan input))
                 (c-code (harlan-format-c c-expr)))
            (if (verbose) (printf c-code))
            (g++-compile-stdin c-code (output-filename filename)))))))

;; (trace-pass
;;  'remove-nested-kernels
;;  'optimize-lift-lets)

(let ((args (parse-args (cdr (command-line)))))
  (unless (null? args)
    (let ((filename (car args)))
      (print-compile-harlan filename))))


;;;; Simple shim for R7RS procedures not in R5RS

;;; Depends on SRFI 4 implementation

(define (boolean=? x y . more)
  (cond
    ((not (dyadic-boolean=? x y)) #f)
    ((null? more) #t)
    (else (apply boolean=? y more))))

(define (dyadic-boolean=? x y)
  (or (and x y) (and (not x) (not y))))

(define (symbol=? x y . more)
  (cond
    ((not (dyadic-symbol=? x y)) #f)
    ((null? more) #t)
    (else (apply symbol=? y more))))

(define (dyadic-symbol=? x y)
  (string=? (symbol->string x) (symbol->string y)))

(define exact inexact->exact)

(define bytevector? u8vector?)

(define bytevector-length u8vector-length)

(define bytevector-u8-ref u8vector-ref)

(define make-bytevector make-u8vector)

(define char-foldcase char-downcase)

(define string-foldcase string-downcase)

(cond-expand
  (chicken-4
    (define (infinite? x) (or (= x +inf.0) (= x -inf.0)))

    (define (nan? x) (not (= x x)))

    (define (exact-integer? obj) (and (integer? obj) (exact? obj)))))

Revert "Place shim definitions in cond-expand for chicken-4"

;;;; Simple shim for R7RS procedures not in R5RS

;;; Depends on SRFI 4 implementation

(define (boolean=? x y . more)
  (cond
    ((not (dyadic-boolean=? x y)) #f)
    ((null? more) #t)
    (else (apply boolean=? y more))))

(define (dyadic-boolean=? x y)
  (or (and x y) (and (not x) (not y))))

(define (symbol=? x y . more)
  (cond
    ((not (dyadic-symbol=? x y)) #f)
    ((null? more) #t)
    (else (apply symbol=? y more))))

(define (dyadic-symbol=? x y)
  (string=? (symbol->string x) (symbol->string y)))

(define exact inexact->exact)

; (define (exact-integer? x) (and (integer? x) (exact? x)))

(define bytevector? u8vector?)

(define bytevector-length u8vector-length)

(define bytevector-u8-ref u8vector-ref)

(define make-bytevector make-u8vector)

(define char-foldcase char-downcase)

(define string-foldcase string-downcase)

;; (define (infinite? x) (or (= x +inf.0) (= x -inf.0)))

;; (define (nan? x) (not (= x x)))

;; (define (exact-integer? obj) (and (integer? obj) (exact? obj)))


<form $FormAttributes data-layout-type="border">

		<% if $Message %>

$Message

		<% else %>

		<% end_if %>

		<fieldset>
			<% if $Legend %><legend>$Legend</legend><% end_if %>
			<% loop $Fields %>
				$FieldHolder
			<% end_loop %>

		</fieldset>

		<% if $Actions %>

			<% loop $Actions %>
				$Field
			<% end_loop %>
			<% if $Controller.LinkPreview %>

					<% _t('SilverStripe\Admin\LeftAndMain.PreviewButton', 'Preview') %> »

			<% end_if %>

		<% end_if %>

</form>

FIX Remove legacy translation behaviour in template

<form $FormAttributes data-layout-type="border">

		<% if $Message %>

$Message

		<% else %>

		<% end_if %>

		<fieldset>
			<% if $Legend %><legend>$Legend</legend><% end_if %>
			<% loop $Fields %>
				$FieldHolder
			<% end_loop %>

		</fieldset>

		<% if $Actions %>

			<% loop $Actions %>
				$Field
			<% end_loop %>
			<% if $Controller.LinkPreview %>

					<%t SilverStripe\Admin\LeftAndMain.PreviewButton 'Preview' %> »

			<% end_if %>

		<% end_if %>

</form>


Add the Lane-Emden differential equation

;; http://mathworld.wolfram.com/Lane-EmdenDifferentialEquation.html
(define-model lane-emden
  (variable xi :independent)
  (variable theta)
  (parameter n :natural)
  (eq (plus (diff (bvar (degree 2) xi) theta)
            (times (divide 2 xi) (diff (bvar xi) theta))
            (power theta n))
      0))


$Question

        $Answer.RichLinks.LimitCharacters(80)

    Link to the full page

Add header link on search results.


<a href="$Link" class="ss-ui-button ui-button add-existing-search" data-icon="magnifier">
	$Title
</a>

Include .action class to add margin styles


#lang typed-scheme

(require typed-scheme/private/extra-procs)

#;(map* + (list 1 2 3) (list 10 20 30) (list 'a 'b 'c))

(: g (Integer Integer Integer  -> Integer))
(define (g x y  z) 0)

(map* g (list 1 2 3) (list 4 5 6))

Add fixed-args mismatch between starred/dotted functions.

#lang typed-scheme

(require typed-scheme/private/extra-procs)

#;(map* + (list 1 2 3) (list 10 20 30) (list 'a 'b 'c))

;; Arity mismatch.
(: g (Integer Integer Integer -> Integer))
(define (g x y z) 0)

(map* g (list 1 2 3) (list 4 5 6))

;; Can't use a starred function with more fixed args
;; for a dotted function.
(: h (Integer Integer Integer * -> Integer))
(define (h x y . z) 0)

(map* h (list 1 2 3) (list 4 5 6))


;; Cyclone Scheme
;; Copyright (c) 2015, Justin Ethier
;; All rights reserved.
;;
;; This module automatically generates the following files:
;;
;; - dispatch.c => Used by apply to call native C functions.
;;
(import (scheme base)
        (scheme file)
        (scheme write))

(with-output-to-file
  "dispatch.c"
  (lambda ()
    (display "
#include \"cyclone/types.h\"
#include \"cyclone/runtime.h\"

void do_dispatch(void *data, int argc, function_type func, object clo, object *b) {
  switch(argc) {" )

    (define bs "")
    (let loop ((i 0))
        (display "case " )
        (display i )
        (display ":func(" )
        (display "data,")
        (display i )
        (display ",clo" )
        (display bs )
        (display ");" )

        (set! bs (string-append bs ",*(b+" (number->string i) ")"))
        (if (< i 129)
          (loop (+ i 1))))

    (display "
  default:
  {
   char buf[1024];
   snprintf(buf, 1023, \"Unhandled number of function arguments: %d\\n\", argc);
   Cyc_rt_raise_msg(data, buf);
  }
  }
}" )))

Increase number of args allowed to 150

;; Cyclone Scheme
;; Copyright (c) 2015, Justin Ethier
;; All rights reserved.
;;
;; This module automatically generates the following files:
;;
;; - dispatch.c => Used by apply to call native C functions.
;;
(import (scheme base)
        (scheme file)
        (scheme write))

(with-output-to-file
  "dispatch.c"
  (lambda ()
    (display "
#include \"cyclone/types.h\"
#include \"cyclone/runtime.h\"

void do_dispatch(void *data, int argc, function_type func, object clo, object *b) {
  switch(argc) {" )

    (define bs "")
    (let loop ((i 0))
        (display "case " )
        (display i )
        (display ":func(" )
        (display "data,")
        (display i )
        (display ",clo" )
        (display bs )
        (display ");" )

        (set! bs (string-append bs ",*(b+" (number->string i) ")"))
        (if (< i 149)
          (loop (+ i 1))))

    (display "
  default:
  {
   char buf[1024];
   snprintf(buf, 1023, \"Unhandled number of function arguments: %d\\n\", argc);
   Cyc_rt_raise_msg(data, buf);
  }
  }
}" )))


; Usage: guile factorielle_optim.scm

(define (fact n)
    (define (fact2 n m)
        (if (= n 1)
            m
            (fact2 (- n 1) (* m n))))
    (fact2 n 1))

(display (fact 10))
(newline)


<% control Messages %>
	<div class="project_message<% if You %> you<% end_if %>">

$Author.Name said on $Created.Nice

$MessageText

		<% if Attachments %>

			<% control Attachments %>

  [$Name <% _t('SSP.ATTACHED','attached') %>]

			<% end_control %>

		<% end_if %>

		<% if PaymentOption %>

				<% control PaymentOption %>
					<% _t('SSPAdmin.PAYMENTOPTION','Payment option') %>: $Description ($Cost.Nice)
					<% _t('SSPAdmin.PAID','Paid?') %> $Paid.Nice
				<% end_control %>

		<% end_if %>

<% end_control %>

FIX - added strong tag


Add a test case with multiple arguments and ordering

;; Copyright 2018 Google LLC
;;
;; Licensed under the Apache License, Version 2.0 (the License);
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;;     http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an AS IS BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.

(library
    (lambda-4)
  (export do-test)
  (import (rnrs))

  ;; Test if we can call lambdas in a local variable
  (define (do-test)
    (let ((fst (lambda (a b) a))
	  (snd (lambda (a b) b)))
      (and (eq? (fst 1 2) 1)
	   (eq? (snd 1 2) 2)))))


<% if $Downloads %>

    <% loop  $Downloads  %>

        $Me.Title

    <% end_loop %>

<% end_if %>

Fix variable names used in templte

<% if $Files %>

    <% loop  $Files %>

        $Title

    <% end_loop %>

<% end_if %>


(define fib ())

(print
 (eval-vm
  '((lambda ()
      (set! fib
            (lambda (n)
              (if (= 0 n)
                0
                (if (= 1 n)
                  1
                  (+ (fib (- n 1)) (fib (- n 2)))))))
      (fib 30)))))
(newline)

;; first heap based vm version
;;
;; $ time ./lisp < samples/fib-vm.scm
;; 832040
;; ./lisp < samples/fib-vm.scm  6.69s user 1.98s system 116% cpu 7.417 total
;;
;;
;; stack based vm version (4.1)
;;
;; $ time ./lisp < samples/fib-vm.scm
;; 832040
;; ./lisp < samples/fib-vm.scm  4.48s user 1.37s system 120% cpu 4.855 total
;;
;;
;; naive interpreter version
;;
;; $ time ./lisp < samples/fib.scm
;; 832040
;; ./lisp < samples/fib.scm  4.16s user 0.52s system 104% cpu 4.454 total

Add stack based vm's benchmark

(define expr
 '(define fib
    (lambda (n)
      (if (= 0 n)
        0
        (if (= 1 n)
          1
          (+ (fib (- n 1)) (fib (- n 2))))))))

(eval-vm expr)

(print (eval-vm '(fib 30)))
(newline)

;; first heap based vm version
;;
;; $ time ./lisp < samples/fib-vm.scm
;; 832040
;; ./lisp < samples/fib-vm.scm  6.69s user 1.98s system 116% cpu 7.417 total
;;
;;
;; stack based vm version (4.1)
;;
;; $ time ./lisp < samples/fib-vm.scm
;; 832040
;; ./lisp < samples/fib-vm.scm  4.48s user 1.37s system 120% cpu 4.855 total
;;
;;
;; stack based vm version (after 4.7)
;;
;; $ time ./lisp < samples/fib-vm.scm
;; 832040
;; ./lisp < samples/fib-vm.scm  4.10s user 0.67s system 84% cpu 5.643 total
;;
;;
;; naive interpreter version
;;
;; $ time ./lisp < samples/fib.scm
;; 832040
;; ./lisp < samples/fib.scm  4.16s user 0.52s system 104% cpu 4.454 total


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='$StylesheetPath'?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
	<% loop $Items %>
        <url>
            <loc>$AbsoluteLink</loc>
            <% if $LastEdited %><lastmod>$LastEdited.Format(y-MM-dd'T'HH:mm:ss)</lastmod><% end_if %>
            <% if $ChangeFrequency %><changefreq>$ChangeFrequency</changefreq><% end_if %>
            <% if $GooglePriority %><priority>$GooglePriority</priority><% end_if %>
            <% if $Locales %><% loop $Locales %><% if $LinkingMode != 'invalid' %>
            <xhtml:link
                rel="alternate"
                hreflang="$LocaleRFC1766"
                href="$AbsoluteLink"
                />
            <% end_if %><% end_loop %><% end_if %>
        </url>
	<% end_loop %>
</urlset>

FIX Quote date format in sitemap template

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='$StylesheetPath'?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
	<% loop $Items %>
        <url>
            <loc>$AbsoluteLink</loc>
            <% if $LastEdited %><lastmod>$LastEdited.Format("y-MM-dd'T'HH:mm:ss")</lastmod><% end_if %>
            <% if $ChangeFrequency %><changefreq>$ChangeFrequency</changefreq><% end_if %>
            <% if $GooglePriority %><priority>$GooglePriority</priority><% end_if %>
            <% if $Locales %><% loop $Locales %><% if $LinkingMode != 'invalid' %>
            <xhtml:link
                rel="alternate"
                hreflang="$LocaleRFC1766"
                href="$AbsoluteLink"
                />
            <% end_if %><% end_loop %><% end_if %>
        </url>
	<% end_loop %>
</urlset>


						Projects & Tickets

<% _t('SSP.EDITPROFILE','Edit profile') %>

<% _t('SSP.LOGOUT','Logout') %>

<% _t('SSP.PROFILEFORM','Edit your profile') %>

				$ProfileForm

FIX - Formatting changes for profile page

<% require themedCSS(page-profile) %>

							<% _t('SSP.PROFILEFORM','Edit profile') %>

<% _t('SSP.YOURPROJECTS','Projects & Tickets') %>

<% _t('SSP.LOGOUT','Logout') %>

				$ProfileForm


; This rule simply inherits the linguistic concept of being definite to any definite noun such as "that man."
; (AN June 2015)

(define definite
    (BindLink
        (VariableList
            (TypedVariableLink
                (VariableNode "$a-parse")
                (TypeNode "ParseNode")
            )
            (TypedVariableLink
                (VariableNode "$noun")
                (TypeNode "WordInstanceNode")
            )
        )
        (AndLink
            (WordInstanceLink
                (VariableNode "$noun")
                (VariableNode "$a-parse")
            )
	    (InheritanceLink
   		(VariableNode "$noun")
   		(DefinedLinguisticConceptNode "definite")
	    )
        )
       (ListLink
        (ExecutionOutputLink
       	   (GroundedSchemaNode "scm: pre-definite-rule")
       	      (ListLink
       	         (VariableNode "$noun")
            )
        )
      )
    )
)

; This is function is not needed. It is added so as not to break the existing
; r2l pipeline.
(define (pre-definite-rule noun)
  (ListLink
    	(definite-rule (cog-name (word-inst-get-lemma str noun)) (cog-name noun)
    )
  )
)

Remove unneeded str variable to get it to work

; This rule simply inherits the linguistic concept of being definite to any definite noun such as "that man."
; (AN June 2015)

(define definite
    (BindLink
        (VariableList
            (TypedVariableLink
                (VariableNode "$a-parse")
                (TypeNode "ParseNode")
            )
            (TypedVariableLink
                (VariableNode "$noun")
                (TypeNode "WordInstanceNode")
            )
        )
        (AndLink
            (WordInstanceLink
                (VariableNode "$noun")
                (VariableNode "$a-parse")
            )
	    (InheritanceLink
   		(VariableNode "$noun")
   		(DefinedLinguisticConceptNode "definite")
	    )
        )
       (ListLink
        (ExecutionOutputLink
       	   (GroundedSchemaNode "scm: pre-definite-rule")
       	      (ListLink
       	         (VariableNode "$noun")
            )
        )
      )
    )
)

; This is function is not needed. It is added so as not to break the existing
; r2l pipeline.
(define (pre-definite-rule noun)
  (ListLink
    	(definite-rule (cog-name (word-inst-get-lemma noun)) (cog-name noun)
    )
  )
)


<% if $UseCompressedAssets %>
<% require javascript("mappable/javascript/google/mappablegoogle.min.js") %>
<% else %>
<% require javascript("mappable/javascript/google/FullScreenControl.js") %>
<% require javascript("mappable/javascript/google/markerclusterer.js") %>
<% require javascript("mappable/javascript/google/maputil.js") %>
<% end_if %>

Include jQuery from framework to get map showing with simple theme

<% require javascript("framework/thirdparty/jquery/jquery.js") %>
<% if $UseCompressedAssets %>
<% require javascript("mappable/javascript/google/mappablegoogle.min.js") %>
<% else %>
<% require javascript("mappable/javascript/google/FullScreenControl.js") %>
<% require javascript("mappable/javascript/google/markerclusterer.js") %>
<% require javascript("mappable/javascript/google/maputil.js") %>
<% end_if %>


;
; define.scm
;
; Demonstrate the use of DefineLink to give names to things.
;
(use-modules (opencog))
(use-modules (opencog query))

(load-from-path "utilities.scm")

;; Some data to populate the atomspace.
(InheritanceLink
	(ConceptNode "battery")
	(ConceptNode "electrical device"))

(InheritanceLink
	(ConceptNode "transistor")
	(ConceptNode "electrical device"))

(EvaluationLink
	(PredicateNode "PartOf")
	(ListLink
		(ConceptNode "battery")
		(VariableNode "car")))

(EvaluationLink
	(PredicateNode "PartOf")
	(ListLink
		(ConceptNode "transistor")
		(VariableNode "phone")))

(EvaluationLink
	(PredicateNode "PartOf")
	(ListLink
		(ConceptNode "windsheild")
		(VariableNode "car")))

;; Define the concept of electrical parts of things.
(define elect-parts
	(DefineLink
		(PredicateNode "Electrical Part Of")
		(AndLink
			(InheritanceLink
				(VariableNode "$x")
				(ConceptNode "electrical device"))
			(EvaluationLink
				(PredicateNode "PartOf")
				(ListLink
					(VariableNode "$x")
					(VariableNode "$y"))))))

;; Define a pattern to find the electrical parts of things
(define get-elect
	(GetLink elect-parts))

;; Search the atomspace for electrical things.
(cog-execute! get-elect)


<form $FormAttributes data-layout-type="border">

		<% if $Message %>

$Message

		<% else %>

		<% end_if %>

		<fieldset>
			<% if $Legend %><legend>$Legend</legend><% end_if %>
			<% loop $Fields %>
				$FieldHolder
			<% end_loop %>

		</fieldset>

		<% if $Actions %>

			<% loop $Actions %>
				$Field
			<% end_loop %>
			<% if $Controller.LinkPreview %>

					<% _t('LeftAndMain.PreviewButton', 'Preview') %> »

			<% end_if %>

		<% end_if %>

</form>

Use panel and toolbar classes, remove legacy classes


(define (main-function)
  (letrec ((main-loop (lambda ()
                        (let ((a (read)) (b (read)))
                          (if (or (eof-object? a) (eof-object? b))
                            #f
                            (begin (display a)
                                   (display a)
                                   <+CURSOR+>
                                   (main-loop)))))))
    (main-loop)))

(main-function)

Fix a bit: rename variable name

(define (main-function)
  (letrec ((main-loop (lambda ()
                        (let ((a (read)) (b (read)))
                          (if (or (eof-object? a) (eof-object? b))
                            #f
                            (begin (display a)
                                   (display b)
                                   <+CURSOR+>
                                   (main-loop)))))))
    (main-loop)))

(main-function)


; Define 2 dummy predicates

(PredicateNode "A")
(PredicateNode "B")

Add TVs to the test predicates

; Define 2 dummy predicates

(PredicateNode "A" (stv 0.2 1))
(PredicateNode "B" (stv 0.6 1))


$Question

        $Answer.RichLinks.LimitCharacters(80)

    $MoreLinkText

Add category to search results if it exists.

$Question

        $Answer.RichLinks.LimitCharacters(80)

    <% if $Category %>
Category: $Category.Name
<% end_if %>
    $MoreLinkText


$Title <% if $Subhead %>$Subhead<% end_if %>

		$Content
		$FoundationForm

		<% include SideBar %>

Update Layout template to match current Foundation Theme

<div class="<% if $Children || $Parent %>large-9 large-push-3<% else %>large-12<% end_if %> columns">

$Title

		$Content
		$FoundationForm

<% if $Children || $Parent %><%--Determine if Side Nav should be rendered, you can change this logic--%>

		<% include SideNav %>

<% end_if %>


$EmailSalutation("Dobrý deň"),

pre potvrdenie Vašej registrácie je potrebné kliknúť na nasledovný odkaz:

$VerificationLink

Ďakujeme za Váš záujem.

S pozdravom,

Iniciatíva slovenských učiteľov

web: www.isu.sk

email: info@isu.sk

Update email address for university strike registration

$EmailSalutation("Dobrý deň"),

pre potvrdenie Vašej registrácie je potrebné kliknúť na nasledovný odkaz:

$VerificationLink

Ďakujeme za Váš záujem.

S pozdravom,

Iniciatíva slovenských učiteľov

web: www.isu.sk

email: ivu@isu.sk


Add a guessing game example, similar to 20 questions

="ll"

;(coll binary_tree
;    left
;    right
;    trait
;    animal
;)

(fun ask_q '(tree) (
        (println "does your animal have %? y/n" tree.trait)
        (let ans (readln "> "))
        (if (== ans "y")
            ; check if right side is none; if so, guess that as the animal
            (if (isnone tree.right)
                (println "I guess that your animal is the %" tree.animal)
                (ask_q tree.right)
            )
        ; else if
        (if (== ans "n")
            (if (isnone tree.left)
                (println "I guess that your animal is the %" tree.animal)
                (ask_q tree.left)
            )
        ; else
        (
            (println "Please enter 'y' or 'n'")
            (ask_q tree)
        )))
    )
)


<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
	<% loop $Pages %>
	<url>
		<loc>$URLSegment</loc>
		<lastmod>$LastEdited</lastmod>
		<changefreq>$ChangeFrequency</changefreq>
		<priority>$Priority</priority>
	</url>
	<% end_loop %>
</urlset>

Add page full link to sitemap template

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
	<% loop $Pages %>
	<url>
		<loc>$AbsoluteLink</loc>
		<lastmod>$LastEdited</lastmod>
		<changefreq>$ChangeFrequency</changefreq>
		<priority>$Priority</priority>
	</url>
	<% end_loop %>
</urlset>


( define (compile-program x)
  (emit ".sub main :main")
  (emit "say ~a" x)
  (emit ".end"))

Use PCT-PAST in generated PIR.

; $Id$
; PAST-Generator for Eclectus

( define (compile-program x)

  (emit ".namespace")

  (emit ".sub '__onload' :init")
  (emit "    load_bytecode 'PGE.pbc'")
  (emit "    load_bytecode 'PGE/Text.pbc'")
  (emit "    load_bytecode 'PGE/Util.pbc'")
  (emit "    load_bytecode 'PGE/Dumper.pbc'")
  (emit "    load_bytecode 'PCT.pbc'")
  (emit ".end")
  (emit "")
  (emit ".sub main :main")
  (emit "")
  (emit "    .local pmc val_x")
  (emit "    val_x = new 'PAST::Val'")
  (emit "    val_x.init( 'value' => '~a', 'returns' => 'Integer' )" x )
  (emit "")
  (emit "    .local pmc var_last")
  (emit "    var_last = new 'PAST::Var'")
  (emit "    var_last.init( 'name' => 'last', 'scope' => 'package', 'lvalue' => 1 )")
  (emit "               ")
  (emit "    .local pmc op_bind")
  (emit "    op_bind = new 'PAST::Op'")
  (emit "    op_bind.init( var_last, val_x, 'pasttype' => 'bind' )")
  (emit "           ")
  (emit "    .local pmc op_say")
  (emit "    op_say = new 'PAST::Op'")
  (emit "    op_say.init( op_bind, 'name' => 'say', 'pasttype' => 'call' )")
  (emit "")
  (emit "    .local pmc stmts")
  (emit "    stmts = new 'PAST::Stmts'")
  (emit "    stmts.'init'( op_say, 'name'=>'stmts' )")
  (emit "")
  (emit "    # compile to PIR and display")
  (emit "    .local pmc astcompiler")
  (emit "    astcompiler = new [ 'PCT::HLLCompiler' ]")
  (emit "    astcompiler.'removestage'('parse')")
  (emit "    astcompiler.'removestage'('past')")
  (emit "")
  (emit "    astcompiler.'eval'(stmts)")
  (emit "")
  (emit ".end")
  (emit "")
  (emit "")
  (emit ".sub 'say'")
  (emit "    .param pmc args :slurpy")
  (emit "    if null args goto end")
  (emit "    .local pmc iter")
  (emit "    iter = new 'Iterator', args")
  (emit "  loop:")
  (emit "    unless iter goto end")
  (emit "    $P0 = shift iter")
  (emit "    print $P0")
  (emit "    goto loop")
  (emit "  end:")
  (emit "    say ''")
  (emit "    .return ()")
  (emit ".end"))


            Enter a date in the following format YYYY-MM-DD.

    <input type="hidden" name="{$Name}_formatted" >
    <input $AttributesHTML data-date-inputformat="D/M/YYYY"
           data-date-displayformat="DD/MM/YYYY"
           placeholder="for example, 27/3/1972" />

    <%-- if $RightTitle %>aria-describedby="{$Name}_right_title" <% end_if --%>

    <button class="accCalendar datePicker datepicker-button" aria-describedby="{$Id}" aria-expanded="false"
        aria-label="You can use this calendar to pick a date">

    </button>

Add type="button" to calendar button

            Enter a date in the following format YYYY-MM-DD.

    <input type="hidden" name="{$Name}_formatted" >
    <input $AttributesHTML data-date-inputformat="D/M/YYYY"
           data-date-displayformat="DD/MM/YYYY"
           placeholder="for example, 27/3/1972" />

    <%-- if $RightTitle %>aria-describedby="{$Name}_right_title" <% end_if --%>

    <button type="button" class="accCalendar datePicker datepicker-button" aria-describedby="{$Id}" aria-expanded="false"
        aria-label="You can use this calendar to pick a date">

    </button>


Add example of component intercommunication on the client side

;; Example of one way of perming component intercommunication on the client side
(load "vaadin.scm")

(define *sym-count* 0)

;; Trivial gensym implementation
(define (gensym)
  (set! *sym-count* (+ *sym-count* 1))
  (string->symbol (string-append "gensym" (number->string *sym-count*))))

;; A macro which defines a label and a slider. The label
;; is updated directly on the client side and RPC is used to
;; transmit the value to the server simultaneously.
(define-macro (slide-label min max listener)
  (let ((lblsym (symbol->string (gensym))))
    `(let* ((lbl (widget
                  (client
                   (let ((text-div (element-new '(div "default"))))
                     (append-to-root text-div)
                     (js-set! (js-eval "window") ,lblsym (lambda (value) (js-set! text-div "innerHTML" value)))))))
            (sldr  (widget
                    (client
                     (let ((slider (element-new
                                    '(input type "range" min ,(number->string min) max ,(number->string max)))))
                       (append-to-root slider)
                       (js-set! slider "oninput"
                                (js-closure (lambda ()
                                              (let ((value (js-ref slider "value")))
                                                (if (not (null? (js-ref (js-eval "window") ,lblsym)))
                                                    ((js-ref (js-eval "window") ,lblsym) (string-append "client: " value)))
                                                (call-server 'value-change value)))))))
                    (server-rpc (value-change value)
                                (,listener value)))))
       (lambda (op)
         (case op
           ((get-slider) sldr)
           ((get-label) lbl))))))

(define *ui* '())

(define *lbl* (Label. "some label"))

(define (main ui)
  (set! *ui* ui)
  (let ((sldr (slide-label 10 200 (lambda (value)
                                    ( .setValue *lbl* (string-append "server: " value)))))
        (hl (HorizontalLayout.)))
    (.setSpacing hl #t)
    (.addComponent hl *lbl*)
    (.addComponent hl (sldr 'get-label))
    (.addComponent ui hl)
    (.addComponent ui (sldr 'get-slider))))


<% with Deployment %>

Deploying to $Project.Name:$Environment.Name

Deploying $SHA

Status:

$ResqueStatus

Deploy log:

$LogContent

<% end_with %>

Fix the project and environment links on the deploy log screen

<% with Deployment %>

Deploying to $Environment.Project.Name:$Environment.Name

Deploying $SHA

Status:

$ResqueStatus

Deploy log:

$LogContent

<% end_with %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <% loop $EmailData %>

          <% if $Type == 'Header' %>

              $Header

          <% else %>
            $Header

              <% if $Value.count %><%-- This is an array --%>

                  <% loop $Value %>
$Item
<% end_loop %>

              <% else %>
                  $Value.XML
              <% end_if %>

          <% end_if %>

      <% end_loop %>

Add default form styling for UL lists

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <% loop $EmailData %>

          <% if $Type == 'Header' %>

              $Header

          <% else %>
            $Header

              <% if $Value.count %><%-- This is an array --%>

                  <% loop $Value %>
$Item
<% end_loop %>

              <% else %>
                  $Value
              <% end_if %>

          <% end_if %>

      <% end_loop %>


<div id="$Name" class="field<% if extraClass %> $extraClass<% end_if %>" <% if DisplayLogic %>data-display-logic-masters="$DisplayLogicMasters"<% end_if %>>
	<% if Title %>$Title<% end_if %>

		$Field

	<% if RightTitle %>$RightTitle<% end_if %>
	<% if Message %>$Message<% end_if %>

	<% if DisplayLogic %>

	<% end_if %>

Use div in display logic eval

<div id="$Name" class="field<% if extraClass %> $extraClass<% end_if %>" <% if DisplayLogic %>data-display-logic-masters="$DisplayLogicMasters"<% end_if %>>
	<% if Title %>$Title<% end_if %>

		$Field

	<% if RightTitle %>$RightTitle<% end_if %>
	<% if Message %>$Message<% end_if %>

	<% if DisplayLogic %>

$DisplayLogic

	<% end_if %>


(define y (lambda (w) (lambda (f) (f (lambda (x) ((w w) f) x )))  ))
(define fix1 (y y))
(define fact (lambda (n)
               (let (nNew n)
                 (if (== nNew 0)
                      1
                      (* nNew (fact (- nNew 1))) ) )))
(define meta-fact
  (lambda (fm)
    (lambda (nm)
      (if (== nm 0)
          1
          (* nm (fm (- nm 1)) ) ) )))

(define fix
  (let (d (lambda (w)
            (lambda (f)
              (f (lambda (x) (((w w) f) x ))) ) ))
    (d d) ) )

--((meta-fact fact) 7)

Fix Y combinator in scheme so that it has some hope of terminating

(define Y
  (lambda (f)
    ((lambda (x) (f (lambda () (x x))))
     (lambda (x) (f (lambda () (x x)))))))

(define ffact
  (lambda (f)
    (lambda (n)
      (if (eq? n 0)
        1
        (* n ((f) (- n 1)))))))

((Y ffact) 7)


<% require css("silverstripe-admintoolbar/css/AdminToolbar.css") %>
<% require javascript("silverstripe-admintoolbar/js/AdminToolbar.js") %>

<% if $BackgroundColor || $ForegroundColor %>
<style>.AdminToolbar {
  <% if $BackgroundColor %>background-color:$BackgroundColor;<% end_if %>
  <% if $ForegroundColor %>color:$ForegroundColor;<% end_if %>
}</style>
<% end_if %>

<div class="AdminToolbar">
  <% include AdminToolbarHide %>
  <% include AdminToolbarNav Nav=$PrimaryNav Variant="primary" %>
  <% include AdminToolbarNav Nav=$SecondaryNav Variant="secondary" %>
</div>

Fix a template syntax issue

<% require css("silverstripe-admintoolbar/css/AdminToolbar.css") %>
<% require javascript("silverstripe-admintoolbar/js/AdminToolbar.js") %>

<% if $BackgroundColor || $ForegroundColor %>
<style>.AdminToolbar {
  <% if $BackgroundColor %>background-color:$BackgroundColor;<% end_if %>
  <% if $ForegroundColor %>color:$ForegroundColor;<% end_if %>
}</style>
<% end_if %>

<div class="AdminToolbar">
  <% include AdminToolbarHide %>
  <% include AdminToolbarNav Nav=$PrimaryNav, Variant="primary" %>
  <% include AdminToolbarNav Nav=$SecondaryNav, Variant="secondary" %>
</div>


(use-modules (unit-test))

(define (excercise1.1 a b c) a)

(assert-equal 0 (excercise1.1 0 0 0))
(assert-equal 1 (excercise1.1 1 0 0))


!<

var x = 1;
var y = 2;
vertex glsl<
  fragment glsl<
    10 * y;
    20 * $3[ if 1 $glsl< x > $glsl< 3 > ]
  >
>

>


<% if Content %>$Content<% end_if %>
<% if StaffCategories %>
	<% loop StaffCategories %>

			<% if Title %>
$Title
<% end_if %>
			<% if Description %>
$Description
<% end_if %>

				<% loop Staff %>
					<% include StaffMembers %>
				<% end_loop %>

	<% end_loop %>
<% end_if %>
<% if UncategorizedStaff %>
	<% if MoreThanOneStaffCategory %>
Other
<% end_if %>

		<% loop UncategorizedStaff %>
			<% include StaffMembers %>
		<% end_loop %>

<% end_if %>

Add some markup for staff categories


#!/usr/local/bin/csi -s

(import chicken scheme)
(use qrencode srfi-1 srfi-4)

(let ((str (if (< (length (argv)) 4)
               "http://call-cc.org"
               (last (argv)))))
  (receive (code width) (QR-encode-string str)
    (print "Encoded: " str)
    (newline)
    (do ((v code)
         (i 0 (add1 i)))
        ((= i (* width width)))
      (when (zero? (modulo i width)) (display "\n        "))
      (display (if (zero? (u8vector-ref code i)) "  " "##")))
    (newline)
    (newline)
    (newline)))

Remove unused line from example

#!/usr/local/bin/csi -s

(import chicken scheme)
(use qrencode srfi-1 srfi-4)

(let ((str (if (< (length (argv)) 4)
               "http://call-cc.org"
               (last (argv)))))
  (receive (code width) (QR-encode-string str)
    (print "Encoded: " str)
    (newline)
    (do ((i 0 (add1 i)))
        ((= i (* width width)))
      (when (zero? (modulo i width)) (display "\n        "))
      (display (if (zero? (u8vector-ref code i)) "  " "##")))
    (newline)
    (newline)
    (newline)))


Add tests for all the pair accessors currently implemented

;; Copyright 2018 Google LLC
;;
;; Licensed under the Apache License, Version 2.0 (the License);
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;;     http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an AS IS BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.

(library
    (pair-accessors)
  (export do-test)
  (import (rnrs))

  (define (do-test)
    (and (eq? 'a (caar '((a b) c)))
         (eq? 'b (cadr '(a b)))
         (eq? 'b (car (cdar '((a b) c))))
         (eq? 'c (car (cddr '(a b c))))
         (eq? 'a (caaar '(((a b) c) d)))
         (eq? 'b (caadr '(a (b c) d)))
         (eq? 'c (car (cddar '((a b c) d))))
         (eq? 'c (caddr '(a b c d)))
         (eq? 'c (car (cdadr '(a (b c) d))))
         (eq? 'd (car (cdddr '(a b c d e))))
         (eq? 'c (caaddr '(a b (c d) e)))
         (eq? 'c (caddar '((a b c) d)))
         (eq? 'c (cadadr '(a (b c) d)))
         (eq? 'c (caddar '((a b c) d)))
         (eq? 'd (car (cdaddr '(a b (c d))))))))


		<% include Breadcrumbs %>

$FirstName $LastName<% if Position %>, $Position<% end_if %>

	<% if MainImage %><% end_if %>
	$Content
	<% if SchoolYear %>
About $FirstName
<% end_if %>

	<% if SchoolYear %>
Year in school: $SchoolYear
<% end_if %>
	<% if HometownAndState %>
Hometown: $HometownAndState
<% end_if %>
	<% if MajorMinor %>
Major / Minor: $MajorMinor
<% end_if %>
	<% if Committees %>
Committee Assignment(s): <% control Committees %>$Title<% if Last %><% else %>, <% end_if %><% end_control %>
<% end_if %>

	$Form

Revert "Revert "branch person fix""

		<% include Breadcrumbs %>

$FirstName $LastName<% if Position %>, $Position<% end_if %>

	<% if MainImage %>
		<% control MainImage.SetWidth(300) %>

		<% end_control %>
	<% end_if %>
	$Content
	<% if SchoolYear %>
About $FirstName
<% end_if %>

	<% if SchoolYear %>
Year in school: $SchoolYear
<% end_if %>
	<% if HometownAndState %>
Hometown: $HometownAndState
<% end_if %>
	<% if MajorMinor %>
Major / Minor: $MajorMinor
<% end_if %>
	<% if Committees %>
Committee Assignment(s): <% control Committees %>$Title<% if Last %><% else %>, <% end_if %><% end_control %>
<% end_if %>

	$Form


	<% loop $Fields %>
	$Field
	<% end_loop %>

Fix category and tag buttons using input groups from bootstrap

        <% loop $Fields %>
            <% if $Type == 'action' %>

                    $Field

            <% else %>
                $Field
            <% end_if %>
        <% end_loop %>


# title: lots of objects
# mode: webgl
# ---

var id = mat4.create();

# Load buffers and parameters for the model.
var mesh = bunny;
var position = mesh_positions(mesh);
var normal = mesh_normals(mesh);
var indices = mesh_indices(mesh);
var size = mesh_size(mesh);

def shade(model: Mat4) (
  vertex glsl<
    gl_Position = projection * view * model * vec4(position, 1.0);
    fragment glsl<
      gl_FragColor = vec4(abs(normal), 1.0);
    >
  >
);

render js<
  var x = 5;
  while (x) (
    x = x - 1;
    var y = 5;
    while (y) (
      y = y - 1;
      var z = 5;
      while (z) (
        z = z - 1;

        var model = mat4.create();
        mat4.translate(model, id, vec3((x - 2) * 10, (y - 2) * 10, (z - 2) * 10));
        shade(model);
        draw_mesh(indices, size);
      )
    )
  )
>

Put the gridification into a function

# title: lots of objects
# mode: webgl
# ---

var id = mat4.create();

# Load buffers and parameters for the model.
var mesh = bunny;
var position = mesh_positions(mesh);
var normal = mesh_normals(mesh);
var indices = mesh_indices(mesh);
var size = mesh_size(mesh);

# A triply-nested loop to draw lots of objects in a grid.
def grid(count: Int, f:(Int Int Int -> Void)) (
  var x = count;
  while (x) (
    x = x - 1;
    var y = count;
    while (y) (
      y = y - 1;
      var z = count;
      while (z) (
        z = z - 1;
        f(x, y, z);
      )
    )
  )
);

# World's simplest shader.
def shade(model: Mat4) (
  vertex glsl<
    gl_Position = projection * view * model * vec4(position, 1.0);
    fragment glsl<
      gl_FragColor = vec4(abs(normal), 1.0);
    >
  >
);

render js<
  grid(5, fun x:Int y:Int z:Int -> (
    var model = mat4.create();
    var pos = vec3(
      (x - 2) * 10,
      (y - 2) * 10,
      (z - 2) * 10
    );
    mat4.translate(model, id, pos);
    shade(model);
    draw_mesh(indices, size);
  ))
>


;
; Opencog attention module
;

(use-modules (opencog))  ; needed for cog-type->int and LTDL

(define-module (opencog attention))

; Load the C library that calls the classserver to load the types.
(load-extension "libattention-types" "attention_types_init")

(load "attention/attention_types.scm")
(load "attention/default-param-values.scm")

Add function for setting the atoms that ecan doesn't consider for spreading

;
; Opencog attention module
;

(use-modules (opencog))  ; needed for cog-type->int and LTDL

(define-module (opencog attention))

; Load the C library that calls the classserver to load the types.
(load-extension "libattention-types" "attention_types_init")

(load "attention/attention_types.scm")
(load "attention/default-param-values.scm")

(define-public (ecan-set-filter . type-symbols)
"
  ecan-set-filter TYPE-SYMBOLS

  Set ecan to filter atoms of TYPE-SYMOBLS.
"
  (if (not (null? type-symbols))
    (StateLink
      SPREADING_FILTER
      (MemberLink
        (map (lambda (x) (TypeNode (symbol->string x))) type-symbols))))

  SPREADING_FILTER
)


    <% loop $AccordionItems %>

                        $Title

                    $Content

    <% end_loop %>

Add position number for multiple accordions


<% if $Title %>

$Title

<% end_if %><% if $Author && $Published %>
<address><%t News.AUTHOR_PUBLISHED Author=$Author Published=$Published.Format(d M Y) %></address><% else_if $Published %>
<address><%t News.AUTHOR Author=$Author %></address><% else_if $Published %>
<address><%t News.PUBLISHED Published=$Published.Format(d M Y) %></address><% end_if %><% if $Summary %>

	$Summary

<% end_if %>

Correct ownership on NewsPage template

<% if $Title %>

$Title

<% end_if %><% if $Author && $Published %>
<address><%t News.AUTHOR_PUBLISHED Author=$Author Published=$Published.Format(d M Y) %></address><% else_if $Author %>
<address><%t News.AUTHOR Author=$Author %></address><% else_if $Published %>
<address><%t News.PUBLISHED Published=$Published.Format(d M Y) %></address><% end_if %><% if $Summary %>

	$Summary

<% end_if %>


;; A temporary test file
(import (scheme base) (scheme write))

   (define-c immutable?
     "(void *data, int argc, closure _, object k, object obj)"
     "object result = boolean_f;
      if (is_object_type(obj) &&
          (type_of(obj) == pair_tag ||
           type_of(obj) == vector_tag ||
           type_of(obj) == bytevector_tag ||
           type_of(obj) == string_tag
          ) &&
          immutable(obj) ) {
        result = boolean_t;
      }
      return_closcall1(data, k, result); ")

(define-c _Cyc-set-immutable!
   "(void *data, int argc, closure _, object k, object obj, object val)"
   "object result = boolean_f;
    if (is_object_type(obj)) {
      immutable(obj) = (val == boolean_f) ? 0 : 1;
      result = boolean_t;
    }
    return_closcall1(data, k, result); ")

(define lis '(1 2 3))

(write
  (list
    (immutable? lis)
    (immutable? (car lis))
    (_Cyc-set-immutable! lis #f)
    (immutable? lis)
    (immutable? (car lis))
    (set-car! lis 'a)
    lis
  )
)

Add scheme code to set immutable field

;; A temporary test file
(import (scheme base) (scheme write))

   (define-c immutable?
     "(void *data, int argc, closure _, object k, object obj)"
     "object result = boolean_f;
      if (is_object_type(obj) &&
          (type_of(obj) == pair_tag ||
           type_of(obj) == vector_tag ||
           type_of(obj) == bytevector_tag ||
           type_of(obj) == string_tag
          ) &&
          immutable(obj) ) {
        result = boolean_t;
      }
      return_closcall1(data, k, result); ")

(define-c _Cyc-set-immutable!
   "(void *data, int argc, closure _, object k, object obj, object val)"
   "object result = boolean_f;
    if (is_object_type(obj)) {
      immutable(obj) = (val == boolean_f) ? 0 : 1;
      result = boolean_t;
    }
    return_closcall1(data, k, result); ")

(define (Cyc-set-immutable! obj val)
  (_Cyc-set-immutable! obj val)
  (cond
    ((pair? obj) (map (lambda (o) (_Cyc-set-immutable! o val)) obj))
    ((vector? obj) (vector-map (lambda (o) (_Cyc-set-immutable! o val)) obj))))

(define lis '(1 2 3))

(write
  (list
    (immutable? lis)
    (immutable? (car lis))
    (Cyc-set-immutable! lis #f)
    (immutable? lis)
    (immutable? (car lis))
    (set-car! lis 'a)
    lis
  )
)


$Content
$Form
<% if $Success %>

$EmailSubmitCompletion

<% else %>
$EnquiryForm
<% end_if %>

Use ID rather than name


(load "interpreter.scm")

; Example
(define load-result (load-words "vocabulary/scrape.scm"))
(define test-vocabulary (car load-result))
(define test-pos-table (cdr load-result))
(define test-interpreter (make-interpreter test-vocabulary universal-grader))
(define test-word (match-word 'a (number-syllables 2)
                                 (rhymes-with "clicker")))
(define test-line (match-line 'b "more-literals"
                                 test-word
                                 (match-word (rhymes-with "corruption"))))
(define test-constraints (poem
                           (match-line 'a
                                       '(syllables 7)
                                       (match-word 'a (has-antonym "hungry"))
                                       "literal"
                                       (match-word 'x (has-synonym "indolent")))
                           (match-line test-word)
                           (match-line '(syllables 6) (match-word (any-word)))
                           (match-line '(syllables 8) (match-word (any-word))
                                                      (match-word (any-word))
                                                      (match-word (any-word)))
                           (match-line 'a)
                           (match-line (match-word 'x) (match-word 'a))
                           test-line))
(define (test)
  (let ((test-poem (test-interpreter test-constraints)))
    test-poem))

Use random choice by default.

(load "interpreter.scm")

; Example
(define load-result (load-words "vocabulary/scrape.scm"))
(define test-vocabulary (car load-result))
(define test-pos-table (cdr load-result))
(define test-interpreter (make-interpreter test-vocabulary random-choice))
(define test-word (match-word 'a (number-syllables 2)
                                 (rhymes-with "clicker")))
(define test-line (match-line 'b "more-literals"
                                 test-word
                                 (match-word (rhymes-with "corruption"))))
(define test-constraints (poem
                           (match-line 'a
                                       '(syllables 7)
                                       (match-word 'a (has-antonym "hungry"))
                                       "literal"
                                       (match-word 'x (has-synonym "indolent")))
                           (match-line test-word)
                           (match-line '(syllables 6) (match-word (any-word)))
                           (match-line '(syllables 8) (match-word (any-word))
                                                      (match-word (any-word))
                                                      (match-word (any-word)))
                           (match-line 'a)
                           (match-line (match-word 'x) (match-word 'a))
                           test-line))
(define (test)
  (let ((test-poem (test-interpreter test-constraints)))
    test-poem))


$SearchForm
<% if Project %>

<% _t('SSPAdmin.BACK','Back') %>

			<% control Project %>

$Title

					<% include Messages %>

			<% end_control %>

			<% if CurrentMember.isAdmin %>
				$CSRDropdown
			<% end_if %>
			$StatusDropdown
			<% if Project.OtherProjects %>

<% _t('SSPAdmin.OTHERPROJECTS','Other projects for this user') %>

				<% control Project %>

					<% control OtherProjects %>

$Title

					<% end_control %>

				<% end_control %>
			<% end_if %>

<% _t('SSPAdmin.ADDMESSAGE','Add message') %>

			$CreateMessageForm

<% else %>
	<% _t('SSPAdmin.PROJECTNOTFOUND','That project could not be found') %>
<% end_if %>

FIX - replaced inline styles with class names


="ll"

(fun get_yn '(prompt)
    (
        (let ans (readln (fmt "% [y/n] " prompt)))
        (if (== ans "y")
            1
        (if (== ans "yes")
            1
        (if (== ans "n")
            0
        (if (== ans "no")
            0
        (
            (println "please enter yes or no")
            (get_yn prompt)
        )))))
    )
)

Change 0s and 1s to ys and ns

="ll"

(fun get_yn '(prompt)
    (
        (let ans (readln (fmt "% [y/n] " prompt)))
        (if (== ans "y")
            "y"
        (if (== ans "yes")
            "y"
        (if (== ans "n")
            "n"
        (if (== ans "no")
            "n"
        (
            (println "please enter yes or no")
            (get_yn prompt)
        )))))
    )
)


<% if Level(2) %>

<% else %>

<% end_if %>

$Title

$Content
<% loop AllChildren %>

$Title
$Summary

<% end_loop %>
$Form
<% include PrevNextSiblingNav %>
<% include TopAndLike %>

<% include SideBar %>

Use page with image portlet image method


(use-modules (unit-test))

(define (square a) (* a a))
(define (excercise1.1 a b c) (+ (square a)
  (if (< b c) (square c)
        (square b))))

(assert-equal 0 (excercise1.1 0 0 0))
(assert-equal 1 (excercise1.1 1 0 0))
(assert-equal 4 (excercise1.1 2 0 0))
(assert-equal 5 (excercise1.1 2 1 0))
(assert-equal 5 (excercise1.1 1 0 2))
(assert-equal 13 (excercise1.1 2 1 3))

Choose second and third, when they are bigger

(use-modules (unit-test))

(define (square a) (* a a))
(define (excercise1.1 a b c)
     (if (< b c)
         (+ (square a) (square c))
         (if (< a b)
             (+ (square b) (square c))
             (+ (square a) (square b)))))

(assert-equal 0 (excercise1.1 0 0 0))
(assert-equal 1 (excercise1.1 1 0 0))
(assert-equal 4 (excercise1.1 2 0 0))
(assert-equal 5 (excercise1.1 2 1 0))
(assert-equal 5 (excercise1.1 1 0 2))
(assert-equal 13 (excercise1.1 2 1 3))
(assert-equal 13 (excercise1.1 1 3 2))


Add a model of Ornstein-Uhlenbeck process

;; Ornstein-Uhlenbeck process
(define-model ornstein-uhlenbeck
  (variable t :independent)
  (variable X :default 10)
  (variable W :Wiener)
  (parameter theta :default 1)
  (parameter sigma :default 1)
  (eq (differential X)
      (plus (times (minus (times theta X)) (differential t))
            (times sigma (differential W))))
  )


ADD - View file for client subscriptions

Viewing Subscription [ID]

for [Jimmy Kung]

				Start Date:<input id="txtStart" type="text" value="12/2/2010" disabled="disabled" />

				End Date:<input id="txtEnd" type="text" value="12/2/2010" disabled="disabled" />

				Bill client $<input id="txtAmt" type="text" value="15.00" disabled="disabled" /> every <input id="txtLength" type="text" value="1" disabled="disabled" />
				<select name="ddlUnit" id="ddlUnit" disabled="disabled">
					<option value="day">day</option>
					<option value="month" selected="selected">month</option>
					<option value="year">year</option>
				</select>(s).

Inactive

Payment was declined.

Update Subscription

Cancel Subscription


;;; This is a program that will find the value of a certain position on
;;; Pascal's Triangle by means of a recursive process. To do this, each
;;; element of the traingle is viewed as a coordinate (col,row), where
;;; col is the column of the element from left to right, and row is the
;;; row of the element. To compute the value of the element, the value
;;; of the element in the same column of the previous row is added to
;;; the value of the preceding column of the previous row. In this,
;;; we are only dealing with positive integers, so if the column or row
;;; are less than or equal to zero, the value of zero is returned.
;;; If at any point the value of the column is equal to one OR if the
;;; value of the column is equal to the value of the row, then one is
;;; returned.
;;;
;;; TL;DR Lookup up Pascal's Triangle online. It's neat.
;;;
;;; Rememebr, this is meant for an interpreter. Do not compile!

(define (pascal-t c r)
  (cond ((or (> c r) (<= c 0) (<= r 0)) 0)
	((or (= c 1) (= c r)) 1)
	(else (+ (pascal-t (- c 1)
			   (- r 1))
		 (pascal-t c (- r 1))))))

Make first condition return false. It makes more sence for integers less than or equal to zero.

;;; This is a program that will find the value of a certain position on
;;; Pascal's Triangle by means of a recursive process. To do this, each
;;; element of the traingle is viewed as a coordinate (col,row), where
;;; col is the column of the element from left to right, and row is the
;;; row of the element. To compute the value of the element, the value
;;; of the element in the same column of the previous row is added to
;;; the value of the preceding column of the previous row. In this,
;;; we are only dealing with positive integers, so if the column or row
;;; are less than or equal to zero, the value of zero is returned.
;;; If at any point the value of the column is equal to one OR if the
;;; value of the column is equal to the value of the row, then one is
;;; returned.
;;;
;;; TL;DR Lookup up Pascal's Triangle online. It's neat.
;;;
;;; Rememebr, this is meant for an interpreter. Do not compile!

(define (pascal-t c r)
  (cond ((or (> c r) (<= c 0) (<= r 0)) #f)
	((or (= c 1) (= c r)) 1)
	(else (+ (pascal-t (- c 1)
			   (- r 1))
		 (pascal-t c (- r 1))))))


;
; Opencog atom-types module
;
(define-module (opencog atom-types))

; Alternately, we could also have
; (define-module (opencog atomtypes nlp-types))
; (define-module (opencog atomtypes spacetime-types))
; and so on, but I don't see the point of that, at the moment...

; (setenv "LTDL_LIBRARY_PATH" "/usr/local/lib/opencog:/usr/local/lib/opencog/modules")

; Load the C libraries that actually call the classserver to load
; the types.
(load-extension "libnlp-types" "nlp_types_init")
(load-extension "libspacetime-types" "spacetime_types_init")
(load-extension "libattention-types" "attention_types_init")
(load-extension "libembodiment-types" "embodiment_types_init")

(load-from-path "nlp/types/nlp_types.scm")
(load-from-path "spacetime/spacetime_types.scm")
(load-from-path "dynamics/attention/attention_types.scm")
(load-from-path "embodiment/embodiment_types.scm")

Add a work-around for python flakiness

;
; Opencog atom-types module
;
(define-module (opencog atom-types))

; Alternately, we could also have
; (define-module (opencog atomtypes nlp-types))
; (define-module (opencog atomtypes spacetime-types))
; and so on, but I don't see the point of that, at the moment...

; XXX Python bug work-around -- python is unable to locate shared
; libraries.  Work around this here, by explicitly setting the
; library path, and the scheme file search path. This is NOT needed
; by the scheme code; but python croaks without this. Go figure...
(setenv "LD_LIBRARY_PATH" "/usr/local/lib/opencog:/usr/local/lib/opencog/modules")
(add-to-load-path "/usr/local/share/opencog/scm")

; Load the C libraries that actually call the classserver to load
; the types.
(load-extension "libnlp-types" "nlp_types_init")
(load-extension "libspacetime-types" "spacetime_types_init")
(load-extension "libattention-types" "attention_types_init")
(load-extension "libembodiment-types" "embodiment_types_init")

(load-from-path "nlp/types/nlp_types.scm")
(load-from-path "spacetime/spacetime_types.scm")
(load-from-path "dynamics/attention/attention_types.scm")
(load-from-path "embodiment/embodiment_types.scm")


; Parse the contents of tagged template literals using
; a language inferred from the tag.

(call_expression
  (identifier) @injection.language
  (template_string) @injection.content)

(call_expression
  (member_expression
    (property_identifier) @injection.language)
  (template_string) @injection.content)

; Parse regex syntax within regex literals

((regex_pattern) @injection.content
 (set! injection.language "regex"))

Add JSDoc to injection query

; Parse the contents of tagged template literals using
; a language inferred from the tag.

(call_expression
  (identifier) @injection.language
  (template_string) @injection.content)

(call_expression
  (member_expression
    (property_identifier) @injection.language)
  (template_string) @injection.content)

; Parse regex syntax within regex literals

((regex_pattern) @injection.content
 (set! injection.language "regex"))

 ; Parse JSDoc annotations in comments

((comment) @injection.content
 (set! injection.language "jsdoc"))


(cons* (channel
        (name 'nonguix)
        (url "https://gitlab.com/nonguix/nonguix"))
       %default-channels)

Add local Guix repo channel configuration

(cons* (channel
        (name 'nonguix)
        (url "https://gitlab.com/nonguix/nonguix"))
       %default-channels)

;; The following channel list can be used when testing patches
;; to services from a local clone of the Guix repo.  Just make
;; sure to commit the changes to a branch and refer to that
;; branch by name in the 'guix channel entry below:

;; (list (channel
;;         (name 'nonguix)
;;         (url "https://gitlab.com/nonguix/nonguix"))
;;       (channel
;;         (name 'guix)
;;         (branch "fix-xfce-power-manager-polkit")
;;         (url "file:///home/daviwil/Projects/Code/guix")))


(begin
  (define display
    (lambda (x) (asm (x) out ())))

  (define true
    (lambda (x y) x))

  (define false
    (lambda (x y) y))

  ;; the primitive eval implements if
  ;; internally
  (define my-if
    (lambda (test t f)
      (test t f)))

  (define tail-bomb
    (lambda (t)
      (display (depth))
      (display " ")
      (gc-stats)
      (t t)))

  (display (true #t #f))
  (display #\newline)

  (display (false #t #f))
  (display #\newline)

  (display (false (false #\a #\b) #\c) )
  (display #\newline)

  (display (true #\@ #f))
  (display #\newline)

  (display
    (my-if true
      '(#\@)
      '(undefined #f)))

  (display #\newline)

  (tail-bomb tail-bomb)
)

Use baselib instead of had defining display.

(begin
  (include "lib/baselib.scm")

  (define true
    (lambda (x y) x))

  (define false
    (lambda (x y) y))

  ;; the primitive eval implements if
  ;; internally
  (define my-if
    (lambda (test t f)
      (test t f)))

  (define tail-bomb
    (lambda (t)
      (display (depth))
      (display " ")
      (gc-stats)
      (t t)))

  (display (true #t #f))
  (display #\newline)

  (display (false #t #f))
  (display #\newline)

  (display (false (false #\a #\b) #\c) )
  (display #\newline)

  (display (true #\@ #f))
  (display #\newline)

  (display
    (my-if true
      '(#\@)
      '(undefined #f)))

  (display #\newline)

  (tail-bomb tail-bomb)
)


#lang typed-scheme

(require typed-scheme/private/extra-procs)

((inst map* Number Number Number Number Number Number Number)
 +
 (list 1 2 3) (list 2 3 4) (list 1 2 3) (list 2 3 4) (list 1 2 3) (list 2 3 4))

Use map instead of map*

#lang typed-scheme

(require typed-scheme/private/extra-procs)

((inst map Number Number Number Number Number Number Number)
 +
 (list 1 2 3) (list 2 3 4) (list 1 2 3) (list 2 3 4) (list 1 2 3) (list 2 3 4))


<% if State %>

	Current testing state

	<% loop State %>

$Name: $Value

	<% end_loop %>

<% end_if %>

Hide testing state by default to avoid perceptual diffs

<% if State %>

	Show testing state

		<% loop State %>

$Name: $Value

		<% end_loop %>

<% end_if %>


var x = 2;
var y = 3;
var n = 0;
while (x) (
  x = x - 1;
  while (y) (
    y = y - 1;
    n = n + 1
  )
);
n
# -> 5

Fix loop nesting in test


;
; Configuration file for the example crisp rule base system (used by
; simple-deduction.scm)
;
; Before running any inference you must load that file

; Load the rules (use load for relative path w.r.t. to that file)
(load "rules/crisp-modus-ponens.scm")
(load "rules/crisp-deduction.scm")

; Define a new rule base (aka rule-based system)
(InheritanceLink
   (ConceptNode "crisp-rule-base")
   (ConceptNode "URE")
)

; Associate the rules to the rule base (with weights, their semantics
; is currently undefined, we might settled with probabilities but it's
; not sure)
(MemberLink (stv 0.4 1)
   crisp-modus-ponens
   (ConceptNode "crisp-rule-base")
)
(MemberLink (stv 0.6 1)
   crisp-deduction
   (ConceptNode "crisp-rule-base")
)

; Termination criteria parameters
(ExecutionLink
   (SchemaNode "URE:maximum-iterations")
   (ConceptNode "crisp-rule-base")
   (NumberNode "20")
)

; Attention allocation (set the TV strength to 0 to disable it, 1 to
; enable it)
(EvaluationLink (stv 0 1)
   (PredicateNode "URE:attention-allocation")
   (ConceptNode "crisp-rule-base")
)

Simplify rule-engine example (add helpers to call fc and bc on that system)

;
; Configuration file for the example crisp rule base system (used by
; simple-deduction.scm)
;
; Before running any inference you must load that file

; Load the rules (use load for relative path w.r.t. to that file)
(load "rules/crisp-modus-ponens.scm")
(load "rules/crisp-deduction.scm")

; Define a new rule base (aka rule-based system)
(define simple-crisp-rbs (ConceptNode "crisp-rule-base"))
(InheritanceLink
   simple-crisp-rbs
   (ConceptNode "URE")
)

; Create helper functions to call the forward and backward chainer on
; that system
(define (simple-crisp-fc source) (cog-fc source simple-crisp-rbs))
(define (simple-crisp-bc target) (cog-bc target simple-crisp-rbs))

; Associate the rules to the rule base (with weights, their semantics
; is currently undefined, we might settled with probabilities but it's
; not sure)
(MemberLink (stv 0.4 1)
   crisp-modus-ponens
   simple-crisp-rbs
)
(MemberLink (stv 0.6 1)
   crisp-deduction
   simple-crisp-rbs
)

; Termination criteria parameters
(ExecutionLink
   (SchemaNode "URE:maximum-iterations")
   simple-crisp-rbs
   (NumberNode "20")
)

; Attention allocation (set the TV strength to 0 to disable it, 1 to
; enable it)
(EvaluationLink (stv 0 1)
   (PredicateNode "URE:attention-allocation")
   simple-crisp-rbs
)


#!/usr/local/bin/csi -s
(define deps
  '(highlighting))

(define depscmd
  (string-intersperse
    `("cabal-dev install --only-dependencies"
      ,@(map (lambda (sym) (format "--flag \"~A\"" sym)) deps))))

(system depscmd)


<% _t('SSP.ORDERDETAILS','Initial Order details') %>

	<% control SelectedOptions %>

			<% control Option %>

$Title ($Price.Nice)

			<% end_control %>
			<% if Attachments %>

				<% control Attachments %>

$Name <% _t('SSP.ATTACHED','attached') %> (download)

				<% end_control %>

			<% end_if %>

	<% end_control %>

Total paid by credit card: $TotalCost.Nice

	<% if Notes %>

<% _t('SSP.NOTES','Notes') %>

$Notes

	<% end_if %>

FIX - added description area so clients can see descriptions of what they ordered

<% _t('SSP.ORDERDETAILS','Initial Order details') %>

	<% control SelectedOptions %>

			<% control Option %>

$Title $Price.Nice

$Description

			<% end_control %>
			<% if Attachments %>

				<% control Attachments %>

$Name <% _t('SSP.ATTACHED','attached') %> download

				<% end_control %>

			<% end_if %>

	<% end_control %>

Total paid by credit card: $TotalCost.Nice

	<% if Notes %>

<% _t('SSP.NOTES','Notes') %>

$Notes

	<% end_if %>


<% if SiteConfig.FacebookLogo %>
<% control SiteConfig.FacebookLogo %>
<meta property="og:image" content="$AbsoluteURL"/>
<meta property="og:image:width" content="$Width"/>
<meta property="og:image:height" content="$height"/>
<% end_control %>
<% end_if %>
<meta property="og:title" content="$Title"/>
<meta property="og:url" content="$AbsoluteLink"/>
<meta property="og:site_name" content="$SiteConfig.Title"/>
<% if $MetaDescription %>
<meta property="og:description" content="$MetaDescription"/>
<% else %>
<meta property="og:description" content="$Content.Summary(50).XML"/>
<% end_if %>
<% if $Locale %>
<meta property="og:locale" content="$Locale"/>
<% end_if %>

Remove HTML entities from description if no meta description is given

<% if SiteConfig.FacebookLogo %>
<% control SiteConfig.FacebookLogo %>
<meta property="og:image" content="$AbsoluteURL"/>
<meta property="og:image:width" content="$Width"/>
<meta property="og:image:height" content="$height"/>
<% end_control %>
<% end_if %>
<meta property="og:title" content="$Title"/>
<meta property="og:url" content="$AbsoluteLink"/>
<meta property="og:site_name" content="$SiteConfig.Title"/>
<% if $MetaDescription %>
<meta property="og:description" content="$MetaDescription"/>
<% else %>
<meta property="og:description" content="$RemoveEntities($Content.Summary(50).XML)"/>
<% end_if %>
<% if $Locale %>
<meta property="og:locale" content="$Locale"/>
<% end_if %>


(cons* (channel
        (name 'next)
        (url "https://gitlab.com/atlas-engineer/next-guix-channel"))
       %default-channels)

Remove Next's Guix channel, add nonguix channel for nonfree packages

(cons* (channel
        (name 'nonguix)
        (url "https://gitlab.com/nonguix/nonguix"))
       %default-channels)


<% if $HasGallery %>

					<% if $Carousel %>

					<% loop GalleryImages %>

						  <img <% with $Image.width(800) %>src="$URL" width="$width" height="$height" <% end_with %>alt="$Title" class="galleryThumb" />

					<% end_loop %>

					<% else %>
					<% loop GalleryImages %>

						  <a rel="gallery" <% with $Image.SetRatioSize(1200, 1200) %>href="$URL"<% end_with %> data-lightbox="gallery"><img <% with $Image.SetRatioSize(150,150) %> data-portrait="<% if $Image.Portrait() %>portrait<% end_if %>" src="$URL" width="$width" height="$height" <% end_with %>alt="$Title"  class="galleryThumb" />

					<% end_loop %>
					<% end_if %>

				<% end_if %>

Set image resize to SetRatioSize

<% if $HasGallery %>

					<% if $Carousel %>

					<% loop GalleryImages %>

						  <img <% with $Image.SetRatioSize(800,600) %>src="$URL" width="$width" height="$height" <% end_with %>alt="$Title" class="galleryThumb" />

					<% end_loop %>

					<% else %>
					<% loop GalleryImages %>

						  <a rel="gallery" <% with $Image.SetRatioSize(1200, 1200) %>href="$URL"<% end_with %> data-lightbox="gallery"><img <% with $Image.SetRatioSize(150,150) %> data-portrait="<% if $Image.Portrait() %>portrait<% end_if %>" src="$URL" width="$width" height="$height" <% end_with %>alt="$Title"  class="galleryThumb" />

					<% end_loop %>
					<% end_if %>

				<% end_if %>


<% if PublicList %>

$ListTitle

		<% loop $PublicList %>

$ItemTitle

				<% if $Image %>

  						{$Image.CroppedImage(120,120)}

				<% end_if %>
				$ItemContent

		<% end_loop %>

	$ListNotes
<% end_if %>

Change Thumbnail size in template to CMS values

<% if PublicList %>

$ListTitle

		<% loop $PublicList %>

$ItemTitle

				<% if $Image %>

  						{$Image.CroppedImage($Up.ThumbnailWidth,$Up.ThumbnailHeight)}

				<% end_if %>
				$ItemContent

		<% end_loop %>

	$ListNotes
<% end_if %>


;
; grammatical class explorer
; Display stats and stuff, about the various word classes.
;
;
How many grammatical classes are there?
(cog-count-atoms 'WordClassNode)

; Show them all
(cog-get-atoms 'WordClassNode)

; Show the members.
(map (lambda (atom) (cog-incoming-by-type atom 'MemberLink))
	(cog-get-atoms 'WordClassNode))

; Print the members
(define (prt-members-of-class CLS)
	(define membs (cog-incoming-by-type CLS 'MemberLink))
	(format #t "Class <~A> has ~A members:\n"
		(cog-name CLS) (length membs))
	(for-each
		(lambda (memb)
			(format #t "      ~A\n" (cog-name (gar memb))))
		membs))

; Print all classes and members
(for-each prt-members-of-class (cog-get-atoms 'WordClassNode))

Load them all, before printing them!

;
; grammatical class explorer
; Display stats and stuff, about the various word classes.
;
; -------------------------------------------------------
;
; Load all grammatical classes from storage
(define (fetch-all-gram-classes)
	(load-atoms-of-type 'WordClassNode)
	(for-each
		(lambda (CLS) (fetch-incoming-by-type CLS 'MemberLink))
		(cog-get-atoms 'WordClassNode)))

; How many grammatical classes are there?
(cog-count-atoms 'WordClassNode)

; Show them all
(cog-get-atoms 'WordClassNode)

; Print the members of one class.
(define (prt-members-of-class CLS)
	(define membs (cog-incoming-by-type CLS 'MemberLink))
	(format #t "Class <~A> has ~A members:\n"
		(cog-name CLS) (length membs))
	(for-each
		(lambda (memb)
			(format #t "      ~A\n" (cog-name (gar memb))))
		membs))

; Print all classes and members
(for-each prt-members-of-class (cog-get-atoms 'WordClassNode))


$Title

        <%-- Brand and toggle get grouped for better mobile display --%>

                SilverStripe

        <%-- Profile menu --%>

        <%-- Navigation top level --%>

                <% loop $Pages %>

                        $MenuTitle.XML

                <% end_loop %>

Add script to set state of nav


					<% control Messages %>

								<div class="<% if You %>you<% else %>admin<% end_if %>">

										<% if You %><% _t('SSP.YOU','You') %><% else %>$Author.FirstName<% end_if %> said on $Created.Format(m-d-Y) at $Created.Format(h:i a)

											$MessageText

										<% if Attachments %>

											<% control Attachments %>

$Name <% _t('SSP.ATTACHED','uploaded') %> (download)

											<% end_control %>

										<% end_if %>
										<% if PaymentOption %>

											<% control PaymentOption %>
												<% if Paid %>
												Added $Description for $Cost.Nice
												<% else %>
												Add $Description for $Cost.Nice
												<% end_if %>
											<% end_control %>

										<% end_if %>

					<% end_control %>

FIX - removed icon; too complicated to mess with appropriate file type icons right now


;check the tense if it is passive
(define (check-tense tense)
	(if (string-contains (cog-name tense) "passive")
		(begin (stv 1 1))
		(begin (stv 0 1))
	)
)

(define passive
	(BindLink
		(VariableList
			(var-decl "$a-parse" "ParseNode")
			(var-decl "$tense" "DefinedLinguisticConceptNode")
		)
		(AndLink
			(word-in-parse "$verb" "$a-parse")
			(word-in-parse "$obj" "$a-parse")
			(InheritanceLink
				(VariableNode "$verb")
				(VariableNode "$tense")
			)
			(dependency "_obj" "$verb" "$obj")
			(EvaluationLink
				(GroundedPredicateNode "scm: check-tense")
				(ListLink
					(VariableNode "$tense")
				)
			)
		)
		(ExecutionOutputLink
			(GroundedSchemaNode "scm: pre-passive-rule")
			(ListLink
				(VariableNode "$verb")
				(VariableNode "$obj")
			)
		)
	)
)

(define (pre-passive-rule verb obj)
	(passive-rule2
		(cog-name (word-inst-get-lemma verb)) (cog-name verb)
		(cog-name (word-inst-get-lemma obj)) (cog-name obj)
	)
)

Add var-decl for verb and obj

;check the tense if it is passive
(define (check-tense tense)
	(if (string-contains (cog-name tense) "passive")
		(begin (stv 1 1))
		(begin (stv 0 1))
	)
)

(define passive
	(BindLink
		(VariableList
			(var-decl "$a-parse" "ParseNode")
			(var-decl "$tense" "DefinedLinguisticConceptNode")
			(var-decl "$verb" "WordInstanceNode")
			(var-decl "$obj" "WordInstanceNode")
		)
		(AndLink
			(word-in-parse "$verb" "$a-parse")
			(word-in-parse "$obj" "$a-parse")
			(InheritanceLink
				(VariableNode "$verb")
				(VariableNode "$tense")
			)
			(dependency "_obj" "$verb" "$obj")
			(EvaluationLink
				(GroundedPredicateNode "scm: check-tense")
				(ListLink
					(VariableNode "$tense")
				)
			)
		)
		(ExecutionOutputLink
			(GroundedSchemaNode "scm: pre-passive-rule")
			(ListLink
				(VariableNode "$verb")
				(VariableNode "$obj")
			)
		)
	)
)

(define (pre-passive-rule verb obj)
	(passive-rule2
		(cog-name (word-inst-get-lemma verb)) (cog-name verb)
		(cog-name (word-inst-get-lemma obj)) (cog-name obj)
	)
)


;
; Self-awareness scheme module for the Eva robot.
; Allows the self-awareness code to be imported as a module.

(define-module (opencog eva-model))

(use-modules (opencog) (opencog atom-types)
	(opencog query) (opencog exec) (opencog python))

; Load various parts....
(load "eva-model/faces.scm")
(load "eva-model/self-model.scm")
(load "eva-model/orchestrate.scm")

; If the ROS node hasn't been loaded yet, then load the "debug"
; python backend. This is needed, so that various imperative
; commands don't crash. A later load of the ROS node will harmlessly
; over-write the python entry-points.
;
; (python-eval
;   "import sys\nsys.path.insert(0, '/usr/local/share/opencog/python')\n")
;
; Hard-coded install path from CMakefile
(python-eval "
# Throws an exception if do_wake_up() is not defined.
try:
    do_wake_up()
except NameError:
    execfile('/usr/local/share/opencog/python/atomic-dbg.py')
")

Make sound localization be a part of the system.

;
; Self-awareness scheme module for the Eva robot.
; Allows the self-awareness code to be imported as a module.

(define-module (opencog eva-model))

(use-modules (opencog) (opencog atom-types)
	(opencog query) (opencog exec) (opencog python))

; Load various parts....
(load "eva-model/faces.scm")
(load "eva-model/self-model.scm")
(load "eva-model/orchestrate.scm")
(load "eva-model/time-map.scm")

; If the ROS node hasn't been loaded yet, then load the "debug"
; python backend. This is needed, so that various imperative
; commands don't crash. A later load of the ROS node will harmlessly
; over-write the python entry-points.
;
; (python-eval
;   "import sys\nsys.path.insert(0, '/usr/local/share/opencog/python')\n")
;
; Hard-coded install path from CMakefile
(python-eval "
# Throws an exception if do_wake_up() is not defined.
try:
    do_wake_up()
except NameError:
    execfile('/usr/local/share/opencog/python/atomic-dbg.py')
")


; This rule simply inherits the linguistic concept of being definite to
; any definite noun such as "that man."
; (AN June 2015)

; Names of things (AN links) will get concatenated by Relex,
; leaving some of the words that make up the name without a lemma.
; Ignore those.
(define-public (check-name lemma)
	(if (equal? "" (cog-name lemma))
		(stv 0 1)
		(stv 1 1)
	)
)

(define definite
	(BindLink
		(VariableList
			(var-decl "$a-parse" "ParseNode")
			(var-decl "$noun" "WordInstanceNode")
			(var-decl "$lemma" "WordNode")
		)
		(AndLink
			(word-in-parse "$noun" "$a-parse")
			(word-lemma "$noun" "$lemma")
			(word-feat "$noun" "definite")
			(EvaluationLink
				(GroundedPredicateNode "scm: check-name")
				(ListLink
					(VariableNode "$lemma")
				)
			)
		)
		(ExecutionOutputLink
			(GroundedSchemaNode "scm: definite-rule")
			(ListLink
				(VariableNode "$lemma")
				(VariableNode "$noun"))
		)
	)
)

Rename a publically exported function

; This rule simply inherits the linguistic concept of being definite to
; any definite noun such as "that man."
; (AN June 2015)

; Names of things (G and AN links) will get concatenated by Relex,
; leaving some of the words that make up the name without a lemma.
; Ignore those.  This is fixed in opencog/relex/pull/243 and so the
; code below can be removed after a few months -- say, after September
; 2016 --  we leave it in as a backwards compat sop for now.
(define-public (r2l-check-name lemma)
	(if (equal? "" (cog-name lemma))
		(stv 0 1)
		(stv 1 1)
	)
)

(define definite
	(BindLink
		(VariableList
			(var-decl "$a-parse" "ParseNode")
			(var-decl "$noun" "WordInstanceNode")
			(var-decl "$lemma" "WordNode")
		)
		(AndLink
			(word-in-parse "$noun" "$a-parse")
			(word-lemma "$noun" "$lemma")
			(word-feat "$noun" "definite")
			(EvaluationLink
				(GroundedPredicateNode "scm: r2l-check-name")
				(ListLink
					(VariableNode "$lemma")
				)
			)
		)
		(ExecutionOutputLink
			(GroundedSchemaNode "scm: definite-rule")
			(ListLink
				(VariableNode "$lemma")
				(VariableNode "$noun"))
		)
	)
)


;; The solution of exercise 2.7
;; Alyssa's program is incomplete because she has not specified the
;; implementation of the interval abstraction. Here is a definition of the
;; interval constructor:
;;
;;     (define (make-interval a b) (cons a b))
;;
;; Define selectors `upper-bound` and `lower-bound` to complete the
;; implementation.
;;
;; -------- (above from SICP)
;;

;; Define intervals
(define (make-interval a b) (cons a b))
(define (lower-bound interval) (car interval))
(define (upper-bound interval) (cdr interval))

(define (add-interval x y)
  (make-interval (+ (lower-bound x) (lower-bound y))
                 (+ (upper-bound x) (upper-bound y))))

(define (mul-interval x y)
  (let ((p1 (* (lower-bound x) (lower-bound y)))
        (p2 (* (lower-bound x) (upper-bound y)))
        (p3 (* (upper-bound x) (lower-bound y)))
        (p4 (* (upper-bound x) (upper-bound y))))
    (make-interval (min p1 p2 p3 p4)
                   (max p1 p2 p3 p4))))

(define (div-interval x y)
  (mul-interval x
                (make-interval (/ 1.0 (upper-bound y))
                               (/ 1.0 (lower-bound y)))))

(define (main)
  (display "Load this file and use `make-interval`")
  (newline))

(main)


;
; OpenCog Pattern matcher module
;

(define-module (opencog query))

; This is also loaded by (opencog exec) We need it here,
; else we get undefined symbols in libquery.
(load-extension "libexecution" "opencog_exec_init")

(load-extension "libquery" "opencog_query_init")

(set-procedure-property! cog-bind 'documentation
"
 cog-bind handle
    Run pattern matcher on handle.  handle must be a BindLink.
    Uses crisp (non-probabilistic) logic during the evaluation
    of evaluatable terms.
")

(set-procedure-property! cog-bind-single 'documentation
"
 cog-bind-single handle
    Run pattern matcher on handle.  handle must be a BindLink.
    The search is terminated after the first match is found.
")

(set-procedure-property! cog-bind-af 'documentation
"
 cog-bind-af handle
    Run pattern matcher on handle.  handle must be a BindLink.
    A special-purpose pattern matcher used by the URE.
")

(set-procedure-property! cog-satisfy 'documentation
"
 cog-satisfy handle
    Run pattern matcher on handle.  handle must be a SatisfactionLink.
    Return a TV. Only satisfaction is performed, no implication.
")

Add a missing library path

;
; OpenCog Pattern matcher module
;

(define-module (opencog query))

; The atomspace libraries are located in /usr/local/lib/opencog
(setenv "LTDL_LIBRARY_PATH" "/usr/local/lib/opencog")

; This is also loaded by (opencog exec) We need it here,
; else we get undefined symbols in libquery.
(load-extension "libexecution" "opencog_exec_init")

(load-extension "libquery" "opencog_query_init")

(set-procedure-property! cog-bind 'documentation
"
 cog-bind handle
    Run pattern matcher on handle.  handle must be a BindLink.
    Uses crisp (non-probabilistic) logic during the evaluation
    of evaluatable terms.
")

(set-procedure-property! cog-bind-single 'documentation
"
 cog-bind-single handle
    Run pattern matcher on handle.  handle must be a BindLink.
    The search is terminated after the first match is found.
")

(set-procedure-property! cog-bind-af 'documentation
"
 cog-bind-af handle
    Run pattern matcher on handle.  handle must be a BindLink.
    A special-purpose pattern matcher used by the URE.
")

(set-procedure-property! cog-satisfy 'documentation
"
 cog-satisfy handle
    Run pattern matcher on handle.  handle must be a SatisfactionLink.
    Return a TV. Only satisfaction is performed, no implication.
")


;
; OpenCog Rule Engine module
;
(define-module (opencog rule-engine))

; We need this to set the LTDL_LIBRARY_PATH
(use-modules (opencog))

(load-extension "libruleengine" "opencog_ruleengine_init")

(load "rule-engine/rule-engine-utils.scm")
(export-rule-engine-utils)

Fix a bad load statement

;
; OpenCog Rule Engine module
;
(define-module (opencog rule-engine))

; We need this to set the LTDL_LIBRARY_PATH
(use-modules (opencog))

(load-extension "libruleengine" "opencog_ruleengine_init")

(load-from-path "rule-engine/rule-engine-utils.scm")
(export-rule-engine-utils)


(library
    (trivial)
  (export do-test)
  (import (rnrs))

  (define (f s)
    1)

  (define (do-test)
    (f "Hello, WebAssembly!")))


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='$StylesheetPath'?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
	<% loop $Items %>
        <url>
            <loc>$AbsoluteLink</loc>
            <% if $LastEdited %><lastmod>$LastEdited.Format("y-MM-dd'T'HH:mm:ss")</lastmod><% end_if %>
            <% if $ChangeFrequency %><changefreq>$ChangeFrequency</changefreq><% end_if %>
            <% if $GooglePriority %><priority>$GooglePriority</priority><% end_if %>
            <% if $Locales %><% loop $Locales %><% if $LinkingMode != 'invalid' %>
            <xhtml:link
                rel="alternate"
                hreflang="$LocaleRFC1766"
                href="$AbsoluteLink"
                />
            <% end_if %><% end_loop %><% end_if %>
        </url>
	<% end_loop %>
</urlset>

Update date format in sitemap template to ensure timezone offset is included as required by Google.

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='$StylesheetPath'?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
	<% loop $Items %>
        <url>
            <loc>$AbsoluteLink</loc>
            <% if $LastEdited %><lastmod>$LastEdited.Rfc3339()</lastmod><% end_if %>
            <% if $ChangeFrequency %><changefreq>$ChangeFrequency</changefreq><% end_if %>
            <% if $GooglePriority %><priority>$GooglePriority</priority><% end_if %>
            <% if $Locales %><% loop $Locales %><% if $LinkingMode != 'invalid' %>
            <xhtml:link
                rel="alternate"
                hreflang="$LocaleRFC1766"
                href="$AbsoluteLink"
                />
            <% end_if %><% end_loop %><% end_if %>
        </url>
	<% end_loop %>
</urlset>