Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defaults:
jobs:
test:
runs-on: ubuntu-latest
container: ingy/exercism-yamlscript-test-runner:0.1.81
container: ingy/exercism-yamlscript-test-runner:0.1.96

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ROOT := $(shell pwd)

BIN := bin

YS_VERSION := 0.1.81
YS_VERSION := 0.1.96

YS_LOCAL := .local
YS_LOCAL_PREFIX := $(YS_LOCAL)/v$(YS_VERSION)
Expand Down
4 changes: 2 additions & 2 deletions bin/generate-stub-program
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
defn main(slug):
data =:
json/load:
slurp: ".problem/exercises/$slug/canonical-data.json"
read: ".problem/exercises/$slug/canonical-data.json"

say: "!yamlscript/v0\n"
say: "!YS-v0\n"

say:
join "\n\n": gen-funcs(data.cases)
Expand Down
7 changes: 3 additions & 4 deletions bin/generate-test-file
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
defn main(slug):
data =:
json/load:
slurp: ".problem/exercises/$slug/canonical-data.json"
read: ".problem/exercises/$slug/canonical-data.json"

tests =: gen-tests(data.cases)

test =: |-
#!/usr/bin/env ys-0

require ys::taptest: :all

use: $slug
use ys::taptest: :all
require: '$slug.ys'
$gen-comments(data)
test::
$(join("\n" tests).trimr())
Expand Down
2 changes: 1 addition & 1 deletion common/gnumakefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))
Expand Down
2 changes: 1 addition & 1 deletion common/meta-makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)

Expand Down
2 changes: 1 addition & 1 deletion docs/SNIPPET.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# A YAMLScript Program!
!yamlscript/v0
!YS-v0

# Define a hello function, 0 or 1 args:
defn hello(name='World'):
Expand Down
7 changes: 3 additions & 4 deletions docs/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ It's actually the first 3 tests from the `acronym` exercise. :-)
```yaml
#!/usr/bin/env ys-0

require ys::taptest: :all

use: acronym
use ys::taptest: :all
load: 'acronym.ys'

test::
- name: Basic
Expand All @@ -74,7 +73,7 @@ The first line is a shebang line that tells the `prove` command (run by the
Makefile) to use the YAMLScript `ys` interpreter to run the tests instead of
`perl` which is the default for `prove`.

The second line is a `require` statement that loads YAMLScript's `ys::taptest`
The second line is a `use` statement that loads YAMLScript's `ys::taptest`
[TAP](https://testanything.org) testing library.

> Note: TAP is a simple text-based interface between test scripts and test
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/acronym/.meta/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)

Expand Down
5 changes: 2 additions & 3 deletions exercises/practice/acronym/.meta/acronym-test.ys
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env ys-0

require ys::taptest: :all

use: acronym
use ys::taptest: :all
load: 'acronym.ys'

test::
- name: Basic
Expand Down
5 changes: 3 additions & 2 deletions exercises/practice/acronym/.meta/acronym.ys
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
!yamlscript/v0
!YS-v0

defn abbreviate(phrase):
uc(phrase).re-seq(/[A-Z']+/)
phrase:str/upper-case
.re-seq(/[A-Z']+/)
.map(first):join
2 changes: 1 addition & 1 deletion exercises/practice/acronym/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))
Expand Down
5 changes: 2 additions & 3 deletions exercises/practice/acronym/acronym-test.ys
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env ys-0

require ys::taptest: :all

use: acronym
use ys::taptest: :all
load: 'acronym.ys'

test::
- name: Basic
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/acronym/acronym.ys
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!yamlscript/v0
!YS-v0

defn abbreviate(phrase):
# Implement the 'abbreviate' function.
2 changes: 1 addition & 1 deletion exercises/practice/all-your-base/.meta/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)

Expand Down
5 changes: 2 additions & 3 deletions exercises/practice/all-your-base/.meta/all-your-base-test.ys
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env ys-0

require ys::taptest: :all

use: all-your-base
use ys::taptest: :all
load: 'all-your-base.ys'

test::
- name: Single bit one to decimal
Expand Down
13 changes: 8 additions & 5 deletions exercises/practice/all-your-base/.meta/all-your-base.ys
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
!yamlscript/v0
!YS-v0

defn rebase(input digits output):
when input < 2: die('input base must be >= 2')
when output < 2: die('output base must be >= 2')
when-not digits.every?(\(0 <= _ <= input.--)):
when-not digits.every?(\(-1 < _ < input)):
die('all digits must satisfy 0 <= d < input base')

loop n reduce(\((%1 * input) + %2) 0 digits), res []:
loop n reduce(\(input.mul(%1).add(%2)) 0 digits), res []:
if n.?:
=>: recur(quot(n output) res.cons(n % output))
res |||: -[0]
recur: quot(n output) res.cons(n % output)
res |||:: [0]

# TODO:
# loop n reduce(\(input * _1 + _2) 0 digits), res []:
2 changes: 1 addition & 1 deletion exercises/practice/all-your-base/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))
Expand Down
5 changes: 2 additions & 3 deletions exercises/practice/all-your-base/all-your-base-test.ys
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env ys-0

require ys::taptest: :all

use: all-your-base
use ys::taptest: :all
load: 'all-your-base.ys'

test::
- name: Single bit one to decimal
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/all-your-base/all-your-base.ys
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!yamlscript/v0
!YS-v0

defn rebase(input-base digits output-base):
# Implement the 'rebase' function.
2 changes: 1 addition & 1 deletion exercises/practice/allergies/.meta/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)

Expand Down
5 changes: 2 additions & 3 deletions exercises/practice/allergies/.meta/allergies-test.ys
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env ys-0

require ys::taptest: :all

use: allergies
use ys::taptest: :all
load: 'allergies.ys'

test::
- name: Not allergic to anything
Expand Down
16 changes: 11 additions & 5 deletions exercises/practice/allergies/.meta/allergies.ys
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
!yamlscript/v0
!YS-v0

hmmm =::
[eggs, peanuts, shellfish,
strawberries, tomatoes,
chocolate, pollen, cats]

defn allergic-to(item score):
list-allergens(score).has?(item)
list-allergens(score)
.has?(item)

defn list-allergens(score):
(0 .. 7).filter(P(bit-test score))
.map(qw(eggs peanuts shellfish strawberries
tomatoes chocolate pollen cats))
(0 .. 7)
.filter(bit-test + score)
.map(hmmm)
2 changes: 1 addition & 1 deletion exercises/practice/allergies/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))
Expand Down
5 changes: 2 additions & 3 deletions exercises/practice/allergies/allergies-test.ys
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env ys-0

require ys::taptest: :all

use: allergies
use ys::taptest: :all
load: 'allergies.ys'

test::
- name: Not allergic to anything
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/allergies/allergies.ys
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!yamlscript/v0
!YS-v0

defn allergic-to(item score):
# Implement the 'allergic-to' function.
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/anagram/.meta/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)

Expand Down
5 changes: 2 additions & 3 deletions exercises/practice/anagram/.meta/anagram-test.ys
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env ys-0

require ys::taptest: :all

use: anagram
use ys::taptest: :all
load: 'anagram.ys'

test::
- name: No matches
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/anagram/.meta/anagram.ys
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
!yamlscript/v0
!YS-v0

defn find-anagrams(subject candidates):
filter _ candidates:
\((_:lc != subject:lc) &&
(_:lc:sort == subject:lc:sort))
\( _:lc.ne(subject:lc) &&
_:lc:sort.eq(subject:lc:sort) )
2 changes: 1 addition & 1 deletion exercises/practice/anagram/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))
Expand Down
5 changes: 2 additions & 3 deletions exercises/practice/anagram/anagram-test.ys
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env ys-0

require ys::taptest: :all

use: anagram
use ys::taptest: :all
load: 'anagram.ys'

test::
- name: No matches
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/anagram/anagram.ys
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!yamlscript/v0
!YS-v0

defn find-anagrams(subject candidates):
# Implement the 'find-anagrams' function.
2 changes: 1 addition & 1 deletion exercises/practice/armstrong-numbers/.meta/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env ys-0

require ys::taptest: :all

use: armstrong-numbers
use ys::taptest: :all
load: 'armstrong-numbers.ys'

test::
- name: Zero is an armstrong number
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!yamlscript/v0
!YS-v0

defn is-armstrong-number(number):
ds =: digits(number)
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/armstrong-numbers/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := bash

BASE := $(shell pwd)

export YS_VERSION := 0.1.81
export YS_VERSION := 0.1.96

YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env ys-0

require ys::taptest: :all

use: armstrong-numbers
use ys::taptest: :all
load: 'armstrong-numbers.ys'

test::
- name: Zero is an armstrong number
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/armstrong-numbers/armstrong-numbers.ys
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!yamlscript/v0
!YS-v0

defn is-armstrong-number(number):
# Implement the 'is-armstrong-number' function.
Loading