Skip to content

Commit

Permalink
[master] make front and back return pointers (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhrr committed Mar 27, 2016
1 parent 3886c72 commit a4dc450
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions modules/array.dt
Original file line number Diff line number Diff line change
Expand Up @@ -482,22 +482,22 @@ must also implement `LessThanComparable`.
#|
@fn front

Returns the value of the first element in the array.
Returns a pointer to the value of the first element in the array.

@param arrp An array reference.
|#
(def front (fn extern (uq T) ((arrp (ref (Array (uq T) (uq N)))))
(@ (source (begin (@ arrp))))))
(def front (fn extern (p (uq T)) ((arrp (ref (Array (uq T) (uq N)))))
(source (begin (@ arrp)))))

#|
@fn back

Returns the value of the last element in the array.
Returns a pointer to the value of the last element in the array.

@param arrp An array reference.
|#
(def back (fn extern (uq T) ((arrp (ref (Array (uq T) (uq N)))))
(@ (source (rbegin (@ arrp))))))
(def back (fn extern (p (uq T)) ((arrp (ref (Array (uq T) (uq N)))))
(source (rbegin (@ arrp)))))

#|
@fn $
Expand Down
12 changes: 6 additions & 6 deletions modules/list.dt
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,24 @@ Expands to a `List` definition over the relevant type.
#|
@fn front

Returns the value of the first element in the list.
Returns a pointer to the value of the first element in the list.

@param lst A list reference.
|#
(def front
(fn extern (uq T) ((lst (ref (const (List (uq T))))))
(@:@ (@:@ lst first) element)))
(fn extern (p (uq T)) ((lst (ref (const (List (uq T))))))
(:@ (@:@ lst first) element)))

#|
@fn back

Returns the value of the last element in the list.
Returns a pointer to the value of the last element in the list.

@param lst A list reference.
|#
(def back
(fn extern (uq T) ((lst (ref (const (List (uq T))))))
(@:@ (@:@ lst last) element)))
(fn extern (p (uq T)) ((lst (ref (const (List (uq T))))))
(:@ (@:@ lst last) element)))

#|
@fn push-back
Expand Down
12 changes: 6 additions & 6 deletions modules/vector.dt
Original file line number Diff line number Diff line change
Expand Up @@ -193,24 +193,24 @@ must also implement `LessThanComparable`.
#|
@fn front

Returns the value of the first element in the vector.
Returns a pointer to the value of the first element in the vector.

@param vecp A vector reference.
|#
(def front
(fn extern (uq T) ((vecp (ref (const (Vector (uq T))))))
(@ (@ (:@ vecp first-element)))))
(fn extern (const (p (uq T))) ((vecp (ref (const (Vector (uq T))))))
(@ (:@ vecp first-element))))

#|
@fn back

Returns the value of the last element in the vector.
Returns a pointer to the value of the last element in the vector.

@param vecp A vector reference.
|#
(def back
(fn extern (uq T) ((vecp (ref (const (Vector (uq T))))))
(@ (@ (:@ vecp last-element)))))
(fn extern (const (p (uq T))) ((vecp (ref (const (Vector (uq T))))))
(@ (:@ vecp last-element))))

#|
@fn pop-back
Expand Down

0 comments on commit a4dc450

Please sign in to comment.