File: string_32.f90

package info (click to toggle)
lfortran 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 46,332 kB
  • sloc: cpp: 137,068; f90: 51,260; python: 6,444; ansic: 4,277; yacc: 2,285; fortran: 806; sh: 524; makefile: 30; javascript: 15
file content (38 lines) | stat: -rw-r--r-- 795 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module string32_mod

    type :: string_type
        sequence
        character(len=:), allocatable :: raw
    end type string_type

    interface operator(//)
        module procedure :: compare_string_type_with_char
    end interface

    contains

    pure function compare_string_type_with_char(s1, s2) result(res)
        type(string_type), intent(in) :: s1
        character(len=*), intent(in) :: s2
        type(string_type) :: res
        res%raw = s1%raw//s2
    end function

end module

program string_32
    use string32_mod, only: string_type, operator(//)
    implicit none

    type(string_type) :: a
    character(len=10) :: b
    type(string_type) :: res
    a%raw = "hi"
    b = "bye"

    res = a // b
    print *, res%raw

    if (res%raw /= "hibye") error stop

end program