• invalidusernamelol [he/him]@hexbear.net
      link
      fedilink
      English
      arrow-up
      6
      ·
      edit-2
      16 days ago
      class Child:
          def __init__(self, name: str) -> None:
              self.name = name
      
      
      class Person:
          def __init__(self, name: str) -> None:
              self.name = name
              self.children = list[Child]()
      
          def adopt(self, child: Child) -> None:
              self.children.append(child)
      
          def __repr__(self) -> str:
              return f'{self.name} has {len(self.children)} kids'
      
      greg = Child("Greg")
      aaron = Person("Aaron")
      aaron.adopt(greg)
      
      • uokgerku [comrade/them, they/them]@hexbear.net
        link
        fedilink
        English
        arrow-up
        8
        ·
        16 days ago
        Welcome to SWI-Prolog (threaded, 64 bits, version 10.0.2)
        SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
        Please run ?- license. for legal details.
        
        For online help and background, visit https://www.swi-prolog.org/
        For built-in help, use ?- help(Topic). or ?- apropos(Word).
        
        15 ?- [user].
        |: child(greg).
        |: cat(greg).
        |: man(aaron).
        |: dad(aaron, greg).
        |: catdad(X, Y) :- dad(X, Y), cat(Y).
        |: ^D% user://1 compiled 0.00 sec, 5 clauses
        true.
        
        15 ?- catdad(aaron, greg).
        true.
        
        18 ?- catdad(X, Y).
        X = aaron,
        Y = greg.
        
        16 ?- [user].
        |: woman(X) :- \+ man(X).
        |: feminism.
        |: buffetavailable(cock, X) :- feminism, woman(X).
        |: ^D% user://2 compiled 0.00 sec, 3 clauses
        true.
        
        17 ?- buffetavailable(cock, aaron).
        false.
        

        pronouns

        spoiler

        Pls forgive the non-monotonic woman reasoning >w<

            • invalidusernamelol [he/him]@hexbear.net
              link
              fedilink
              English
              arrow-up
              4
              ·
              16 days ago

              I’ve never really used Rust, but I’m one of those python programmers that writes 50/50 type hints and actual code lol.

              Type systems are really fun to play with. Haskell and Prolog are basically just types as code and I love it.

              Writing a ton of Protocols in Python and composing them together is really fun. The flexibility of using the type system with the runtime ducks of Python is actually really sweet. The strict duck is actually really useful in practice too. Plenty of times I need to break strictness to let something busted in the pipeline through.