perfect-cube.scm 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/guile \
  2. -e main -s
  3. !#
  4. ;; This program tries to find a perfect 3d triangle ie:
  5. ;; A^2 + B^2 + C^2 = D^2
  6. ;; use these modules to help my process the command line arguments.
  7. (use-modules (ice-9 getopt-long))
  8. (use-modules (ice-9 regex))
  9. (define (main args)
  10. ;;the option specification tells getopt-long how
  11. ;; to parse the command line
  12. (let* ((option-spec '((version (single-char #\v) (value #f))
  13. (help (single-char #\h) (value #f))
  14. (number (single-char #\n) (value #t)
  15. ;; (required #t)
  16. )))
  17. ;; tell getopt-long to parse the command line and put the
  18. ;; data in options
  19. (options (getopt-long args option-spec))
  20. ;; was --help or -h used?
  21. (help-wanted (option-ref options 'help #f))
  22. (version-wanted (option-ref options 'version #f))
  23. ;; was -c or --calc used? If there was no value given,
  24. ;; then return #f
  25. (number-wanted (option-ref options 'number #f)))
  26. (if (or version-wanted help-wanted)
  27. (begin
  28. (if version-wanted
  29. (display "repeat version 0.1\n"))
  30. (if help-wanted
  31. (begin
  32. (display "repeat [options]\n")
  33. (display "-v --version Display version\n")
  34. (display "-h, --help Display this help info\n")
  35. (display "-n, --number Does this number repeat?\n")
  36. )))
  37. (display "help"))))