Skip to content

Commit

Permalink
use keyword to represent field from record; alpha release
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Apr 26, 2021
1 parent e4b187d commit af04065
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "calcit_runner"
version = "0.3.0-a3"
version = "0.3.0-a4"
authors = ["jiyinyiyong <jiyinyiyong@gmail.com>"]
edition = "2018"
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions calcit/snapshots/test-record.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

assert=
keys p2
[] |age |name |position
[] :age :name :position

assert-detect identity $ relevant-record? p1 p1
assert-detect identity $ relevant-record? p1 p2
Expand Down Expand Up @@ -81,7 +81,7 @@
assert= 3 $ count p1
assert=
nth p1 1
[] |name |Chen
[] :name |Chen

assert= 21
get (update p1 :age inc) :age
Expand Down
4 changes: 2 additions & 2 deletions lib/calcit-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ export class CrDataMap {
if (shorter) {
let keyPart = isNestedCrData(k) ? tipNestedCrData(k) : toString(k, true);
let valuePart = isNestedCrData(v) ? tipNestedCrData(v) : toString(k, true);
itemsCode = ` (${itemsCode}${keyPart} ${valuePart})`;
itemsCode = `${itemsCode} (${keyPart} ${valuePart})`;
} else {
itemsCode = ` (${itemsCode}${toString(k, true)} ${toString(v, true)})`;
itemsCode = `${itemsCode} (${toString(k, true)} ${toString(v, true)})`;
}
}
return `({}${itemsCode})`;
Expand Down
4 changes: 2 additions & 2 deletions lib/calcit.procs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export let nth = function (xs: CrDataValue, k: CrDataValue) {
if (k < 0 || k >= xs.fields.length) {
throw new Error("Out of bound");
}
return new CrDataList([xs.fields[k], xs.values[k]]);
return new CrDataList([kwd(xs.fields[k]), xs.values[k]]);
}
if (Array.isArray(xs)) {
return xs[k];
Expand Down Expand Up @@ -886,7 +886,7 @@ export let to_pairs = (xs: CrDataValue): CrDataValue => {
} else if (xs instanceof CrDataRecord) {
let arr_result: Array<CrDataList> = [];
for (let idx in xs.fields) {
arr_result.push(new CrDataList([xs.fields[idx], xs.values[idx]]));
arr_result.push(new CrDataList([kwd(xs.fields[idx]), xs.values[idx]]));
}
return new CrDataList(arr_result);
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@calcit/procs",
"version": "0.3.0-a3",
"version": "0.3.0-a4",
"main": "./lib/calcit.procs.js",
"devDependencies": {
"@types/node": "^14.14.41",
Expand Down
2 changes: 1 addition & 1 deletion src/builtins/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn nth(xs: &CalcitItems) -> Result<Calcit, String> {
Ok(idx) => {
if idx < fields.len() {
Ok(Calcit::List(im::vector![
Calcit::Str(fields[idx].clone()),
Calcit::Keyword(fields[idx].clone()),
values[idx].clone()
]))
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/builtins/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub fn to_pairs(xs: &CalcitItems) -> Result<Calcit, String> {
let mut zs: CalcitItems = im::vector![];
for idx in 0..fields.len() {
zs.push_back(Calcit::List(im::vector![
Calcit::Str(fields[idx].clone()),
Calcit::Keyword(fields[idx].clone()),
values[idx].clone(),
]));
}
Expand Down
2 changes: 1 addition & 1 deletion src/primes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ impl PartialEq for Calcit {
pub const CORE_NS: &str = "calcit.core";
pub const GENERATED_NS: &str = "calcit.gen";

pub const CALCI_VERSION: &str = "0.3.0-a3";
pub const CALCI_VERSION: &str = "0.3.0-a4";

impl Calcit {
pub fn turn_string(&self) -> String {
Expand Down

0 comments on commit af04065

Please sign in to comment.