Author: | nomennescio |
---|---|

Mode: | factor |

Date: | Sun, 16 Jan 2022 23:01:52 |

! 2022 nomennescio USING: kernel lexer math parser words.constant ; IN: indices SYNTAX: INDEX: 0 ";" [ create-word-in over define-constant 1 + ] each-token drop ; ! usage: ! INDEX: zero one two three four five six seven eight nine ; ! INDEX: sunday monday tuesday wednesday thursday friday saturday ; ! idea for additional words : "+INDEX:" to start counting from an offset

Author: | nomennescio |
---|---|

Mode: | factor |

Date: | Sun, 16 Jan 2022 23:09:37 |

SYNTAX: +INDEX: scan-number ";" [ create-word-in over define-constant 1 + ] each-token drop ; ! usage : ! +INDEX: 0 zero one two three four five six seven eight nine ;

Author: | nomennescio |
---|---|

Mode: | factor |

Date: | Sun, 16 Jan 2022 23:14:32 |

! 2022 nomennescio USING: kernel lexer math parser words.constant ; IN: indices : (create-indices) ( n -- m ) ";" [ create-word-in over define-constant 1 + ] each-token ; SYNTAX: INDEX: 0 (create-indices) drop ; SYNTAX: +INDEX: scan-number (create-indices) drop ; ! usage: ! INDEX: zero one two three four five six seven eight nine ; ! INDEX: sunday monday tuesday wednesday thursday friday saturday ; ! usage : ! +INDEX: 0 zero one two three four five six seven eight nine ;

Author: | nomennescio |
---|---|

Mode: | factor |

Date: | Mon, 17 Jan 2022 10:15:06 |

One could argue the 0 based index would be the exceptional situation, and having a numerical argument the base case. The following reflect that in their naming SYNTAX: 0INDEX: 0 (create-indices) drop ; SYNTAX: INDEX: scan-number (create-indices) drop ;

Author: | nomennescio |
---|---|

Mode: | factor |

Date: | Tue, 18 Jan 2022 04:14:24 |

Given the common cases of 0 or 1 based indices, one could say a single version of the word which always has a numerical argument would suffice. INDEX: 0 zero one two three four five six seven eight nine ; INDEX: 0 sunday monday tuesday wednesday thursday friday saturday ; As an alternative name, John Benediktsson suggested INDEX-FROM: for +INDEX

Author: | nomennescio |
---|---|

Mode: | factor |

Date: | Tue, 18 Jan 2022 04:35:08 |

SYNTAX: INDEX0: 0 (create-indices) drop ; SYNTAX: INDEX1: 1 (create-indices) drop ; SYNTAX: INDEX: scan-number (create-indices) drop ;

Author: | nomennescio |
---|---|

Mode: | factor |

Date: | Tue, 3 Oct 2023 11:01:32 |

INDEX: sunday monday tuesday wednesday thursday friday saturday ; \ sunday present -> "sunday"

Author: | nomennescio |
---|---|

Mode: | factor |

Date: | Tue, 3 Oct 2023 11:14:30 |

IN: your-vocab INDEX: sunday monday tuesday wednesday thursday friday saturday ; ! the current vocab is a bit cumbersome : >index ( string -- index ) manifest get current-vocab>> lookup-word ; "sunday" >index -> sunday

Author: | nomennescio |
---|---|

Mode: | factor |

Date: | Tue, 3 Oct 2023 11:42:16 |

! only works in parsing words "sunday" search -> sunday

Summary: | |
---|---|

Author: | |

Mode: | |

Body: | |