From b56e5d599d6547be6718634aa698a097cb9e82f6 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 13 Sep 2024 02:55:46 +0100 Subject: vectors: Rename module to (ravanan work vectors). * ravanan/vectors.scm: Move to ravanan/work/vectors.scm. * ravanan/command-line-tool.scm, ravanan/job-state.scm, ravanan/reader.scm, ravanan/workflow.scm: Import (ravanan work vectors) instead of (ravanan vectors). --- ravanan/command-line-tool.scm | 2 +- ravanan/job-state.scm | 2 +- ravanan/reader.scm | 2 +- ravanan/vectors.scm | 98 ------------------------------------------- ravanan/work/vectors.scm | 98 +++++++++++++++++++++++++++++++++++++++++++ ravanan/workflow.scm | 2 +- 6 files changed, 102 insertions(+), 102 deletions(-) delete mode 100644 ravanan/vectors.scm create mode 100644 ravanan/work/vectors.scm diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm index df7e8fa..8815211 100644 --- a/ravanan/command-line-tool.scm +++ b/ravanan/command-line-tool.scm @@ -51,12 +51,12 @@ #:use-module (ravanan propnet) #:use-module (ravanan reader) #:use-module (ravanan slurm-api) - #:use-module (ravanan vectors) #:use-module (ravanan work command-line-tool) #:use-module (ravanan work monads) #:use-module (ravanan work types) #:use-module (ravanan work ui) #:use-module (ravanan work utils) + #:use-module (ravanan work vectors) #:export (run-command-line-tool command-line-tool-scheduler check-requirements diff --git a/ravanan/job-state.scm b/ravanan/job-state.scm index fc0045a..8944035 100644 --- a/ravanan/job-state.scm +++ b/ravanan/job-state.scm @@ -27,7 +27,7 @@ (define-module (ravanan job-state) #:use-module (srfi srfi-9 gnu) #:use-module (ravanan slurm-api) - #:use-module (ravanan vectors) + #:use-module (ravanan work vectors) #:export (single-machine-job-state slurm-job-state diff --git a/ravanan/reader.scm b/ravanan/reader.scm index a4c2002..69c9d55 100644 --- a/ravanan/reader.scm +++ b/ravanan/reader.scm @@ -23,10 +23,10 @@ #:use-module (ice-9 match) #:use-module (json) #:use-module (yaml) - #:use-module (ravanan vectors) #:use-module (ravanan work command-line-tool) #:use-module (ravanan work monads) #:use-module (ravanan work utils) + #:use-module (ravanan work vectors) #:export (read-workflow read-inputs)) diff --git a/ravanan/vectors.scm b/ravanan/vectors.scm deleted file mode 100644 index 9c0dd49..0000000 --- a/ravanan/vectors.scm +++ /dev/null @@ -1,98 +0,0 @@ -;;; ravanan --- High-reproducibility CWL runner powered by Guix -;;; Copyright © 2024 Arun Isaac -;;; -;;; This file is part of ravanan. -;;; -;;; ravanan is free software: you can redistribute it and/or modify it -;;; under the terms of the GNU General Public License as published by -;;; the Free Software Foundation, either version 3 of the License, or -;;; (at your option) any later version. -;;; -;;; ravanan is distributed in the hope that it will be useful, but -;;; WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;;; General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with ravanan. If not, see . - -(define-module (ravanan vectors) - #:use-module ((rnrs base) #:select (vector-for-each vector-map)) - #:use-module (srfi srfi-1) - #:use-module ((srfi srfi-43) #:select (vector-append - (vector-map . vector-map-indexed) - vector-any - vector-every - vector-fold)) - #:export (vector-map->list - vector-append-map - vector-append-map->list - map->vector - vector-filter - vector-filter-map->list - vector-remove - vector-find) - #:re-export (vector-append - vector-for-each - vector-map - vector-map-indexed - vector-any - vector-every)) - -(define (vector-map->list proc first-vector . other-vectors) - "Map @var{proc} over vectors and return a list of the results." - (reverse - (apply vector-fold - (lambda (_ result . elements) - (cons (apply proc elements) - result)) - (list) - first-vector - other-vectors))) - -(define (vector-append-map proc first-vector . other-vectors) - "Map @var{proc} over vectors and return a vector of the results appended -together." - (apply vector-fold - (lambda (_ result . elements) - (vector-append result - (apply proc elements))) - (vector) - first-vector - other-vectors)) - -(define (vector-append-map->list proc first-vector . other-vectors) - "Map @var{proc} over vectors and return a list of the results appended -together." - (apply vector-fold - (lambda (_ result . elements) - (append result - (apply proc elements))) - (list) - first-vector - other-vectors)) - -(define (map->vector proc first-list . other-lists) - "Map @var{proc} over lists and return a vector of the results." - (list->vector (apply map proc first-list other-lists))) - -(define (vector-filter pred vec) - "Return a vector with elements from @var{vec} that pass @var{pred}." - (list->vector (filter pred (vector->list vec)))) - -(define (vector-filter-map->list proc vec) - "Map @var{proc} over @var{vec} and return a list of the results that are not -@code{#f}." - (filter-map proc (vector->list vec))) - -(define (vector-remove proc vec) - "Return a vector with elements from @var{vec} that fail @var{pred}." - (vector-filter (negate proc) vec)) - -(define (vector-find pred vec) - "Return the first element of @var{vec} that pass @var{pred}. If no such -element exists, return @code{#f}." - (vector-any (lambda (x) - (and (pred x) - x)) - vec)) diff --git a/ravanan/work/vectors.scm b/ravanan/work/vectors.scm new file mode 100644 index 0000000..160ff3e --- /dev/null +++ b/ravanan/work/vectors.scm @@ -0,0 +1,98 @@ +;;; ravanan --- High-reproducibility CWL runner powered by Guix +;;; Copyright © 2024 Arun Isaac +;;; +;;; This file is part of ravanan. +;;; +;;; ravanan is free software: you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; ravanan is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with ravanan. If not, see . + +(define-module (ravanan work vectors) + #:use-module ((rnrs base) #:select (vector-for-each vector-map)) + #:use-module (srfi srfi-1) + #:use-module ((srfi srfi-43) #:select (vector-append + (vector-map . vector-map-indexed) + vector-any + vector-every + vector-fold)) + #:export (vector-map->list + vector-append-map + vector-append-map->list + map->vector + vector-filter + vector-filter-map->list + vector-remove + vector-find) + #:re-export (vector-append + vector-for-each + vector-map + vector-map-indexed + vector-any + vector-every)) + +(define (vector-map->list proc first-vector . other-vectors) + "Map @var{proc} over vectors and return a list of the results." + (reverse + (apply vector-fold + (lambda (_ result . elements) + (cons (apply proc elements) + result)) + (list) + first-vector + other-vectors))) + +(define (vector-append-map proc first-vector . other-vectors) + "Map @var{proc} over vectors and return a vector of the results appended +together." + (apply vector-fold + (lambda (_ result . elements) + (vector-append result + (apply proc elements))) + (vector) + first-vector + other-vectors)) + +(define (vector-append-map->list proc first-vector . other-vectors) + "Map @var{proc} over vectors and return a list of the results appended +together." + (apply vector-fold + (lambda (_ result . elements) + (append result + (apply proc elements))) + (list) + first-vector + other-vectors)) + +(define (map->vector proc first-list . other-lists) + "Map @var{proc} over lists and return a vector of the results." + (list->vector (apply map proc first-list other-lists))) + +(define (vector-filter pred vec) + "Return a vector with elements from @var{vec} that pass @var{pred}." + (list->vector (filter pred (vector->list vec)))) + +(define (vector-filter-map->list proc vec) + "Map @var{proc} over @var{vec} and return a list of the results that are not +@code{#f}." + (filter-map proc (vector->list vec))) + +(define (vector-remove proc vec) + "Return a vector with elements from @var{vec} that fail @var{pred}." + (vector-filter (negate proc) vec)) + +(define (vector-find pred vec) + "Return the first element of @var{vec} that pass @var{pred}. If no such +element exists, return @code{#f}." + (vector-any (lambda (x) + (and (pred x) + x)) + vec)) diff --git a/ravanan/workflow.scm b/ravanan/workflow.scm index 0f4bcdb..86f6160 100644 --- a/ravanan/workflow.scm +++ b/ravanan/workflow.scm @@ -24,11 +24,11 @@ #:use-module (ravanan command-line-tool) #:use-module (ravanan propnet) #:use-module (ravanan reader) - #:use-module (ravanan vectors) #:use-module (ravanan work command-line-tool) #:use-module (ravanan work monads) #:use-module (ravanan work ui) #:use-module (ravanan work utils) + #:use-module (ravanan work vectors) #:export (run-workflow)) (define %supported-requirements -- cgit v1.2.3