Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docstring to lisp #490

Merged
merged 7 commits into from May 29, 2023
Merged

Add docstring to lisp #490

merged 7 commits into from May 29, 2023

Conversation

vinc
Copy link
Owner

@vinc vinc commented May 26, 2023

  • Add doc function
  • Add optional doc parameter to def
  • Document core functions
  • Add could_not and expected macros to keep the code DRY
  • Add env function

@vinc
Copy link
Owner Author

vinc commented May 26, 2023

Docstring example:

(def (map f ls)
  "Apply function to list"
  (if (nil? ls) nil
    (cons
      (f (first ls))
      (map f (rest ls)))))

(doc map) # => "Apply function to list"

@vinc
Copy link
Owner Author

vinc commented May 28, 2023

Add env function to list the symbols defined in the environment

@vinc
Copy link
Owner Author

vinc commented May 29, 2023

Doc generation:

(load "/lib/lisp/core.lsp")

(map
  (fun (s)
    (print (str
      "- __"
      s
      "__ `("
      (type (eval s))
      " "
      (second (parse (str (eval s))))
      ")`: "
      (doc (eval s)))))
  (filter
    (fun (s)
      (or (fun? (eval s)) (mac? (eval s))))
    (rev (env))))
  • % (function args):
  • * (function args):
  • + (function args):
  • - (function args):
  • / (function args):
  • < (function args):
  • << (function args):
  • <= (function args):
  • = (function args):
  • > (function args):
  • >= (function args):
  • >> (function args):
  • ^ (function args):
  • abs (function (x)):
  • acos (function args):
  • and (macro (x y)):
  • append (function args):
  • append-file (function (path s)): Append string to file
  • append-file-binary (function args):
  • asin (function args):
  • atan (function args):
  • bin->num (function args):
  • bin->str (function args):
  • binary->number (function args):
  • binary->string (function args):
  • bool? (function (x)):
  • boolean? (function (x)):
  • chars (function (contents)): Split contents into a list of chars
  • chunks (function args):
  • contains? (function args):
  • cos (function args):
  • def (macro args):
  • def-fun (macro args):
  • def-mac (macro args):
  • eq? (macro args):
  • filter (function (f ls)): Filter the elements of the list with the function
  • first (function (lst)):
  • fun (macro args):
  • fun? (function (x)):
  • function? (function (x)):
  • help (macro args):
  • intersection (function (a b)): Return elements found in both lists
  • join-str (function (ls s)): Join the elements of the list with the string
  • join-string (function (ls s)): Join the elements of the list with the string
  • last (function (lst)):
  • len (function args):
  • length (function args):
  • let (macro (params values body)):
  • lines (function (contents)): Split contents into a list of lines
  • list (function args):
  • list? (function (x)):
  • mac (macro args):
  • mac? (function (x)):
  • macro? (function (x)):
  • map (function (f ls)): Apply the function to the elements of the list
  • max (function (lst)): Return the maximum element of the list
  • min (function (lst)): Return the minimum element of the list
  • nil? (function (x)):
  • not (function (x)):
  • nth (function args):
  • num->bin (function args):
  • num-type (function args):
  • num? (function (x)):
  • number->binary (function args):
  • number-type (function args):
  • number? (function (x)):
  • or (macro (x y)):
  • p (function (exp)): Print expression to the console
  • parse (function args):
  • print (function (exp)): Print expression to the console with a newline
  • range (function (start stop)): Return a list of integers from start to stop excluded
  • read-char (function ()): Read char from the console
  • read-file (function args):
  • read-file-binary (function args):
  • read-line (function ()): Read line from the console
  • realtime (function ()):
  • reduce (function (f ls)): Reduce the elements of the list with the function
  • regex-find (function args):
  • regex-match? (function (pattern s)):
  • rest (macro args):
  • rev (function (x)): Reverse list
  • reverse (function (x)): Reverse list
  • second (function (lst)):
  • sin (function args):
  • slice (function args):
  • sort (function args):
  • split (function args):
  • str (function args):
  • str->bin (function args):
  • str->num (function args):
  • str? (function (x)):
  • string (function args):
  • string->binary (function args):
  • string->number (function args):
  • string? (function (x)):
  • sym? (function (x)):
  • symbol? (function (x)):
  • system (function args):
  • tan (function args):
  • third (function (lst)):
  • trim (function args):
  • trunc (function args):
  • type (function args):
  • uniq (function args):
  • unique (function args):
  • uptime (function ()):
  • var (macro args):
  • words (function (contents)): Split contents into a list of words
  • write-file (function (path s)): Write string to file
  • write-file-binary (function args):

@vinc vinc marked this pull request as ready for review May 29, 2023 07:20
@vinc vinc merged commit b1d7a1f into trunk May 29, 2023
1 check passed
@vinc vinc deleted the feature/add-docstring-to-lisp branch May 29, 2023 08:15
@vinc vinc mentioned this pull request Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant